"mock-maker-inline" prevents collection of code coverage for spys
See original GitHub issueHi,
Being one of JaCoCo (Java Code Coverage Library) developers, I was curious about interoperability of Mockito 2.2.x and JaCoCo on-the-fly instrumentation (using agent), so did some tests and came across following behavior:
with mock-maker-inline
:
without:
Here is small example that reproduces this behavior - example.zip , mvn clean verify
to run tests and generate JaCoCo report.
- Mockito 2.2.16
- JaCoCo 0.7.7
- JDK 8u102
As a workaround possible to use JaCoCo offline instrumentation (mvn clean verify -Djacoco-offline
on the given example), but we don’t recommend this mode and it is not available nor in EclEmma (plugin for Eclipse based on JaCoCo), nor when using JaCoCo in IntellIJ IDEA.
Also should be noted that the same happens for IntelliJ IDEA’s own built-in coverage engine:
vs
Unfortunately, I didn’t had time (yet) to dig deeper into code of Mockito to understand why this happens. Best guess based on investigation of similar issue with PowerMock: Mockito’s agent bypasses other agents by reading class files from disk.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:23 (12 by maintainers)
Top GitHub Comments
I’ve never used java and mockito, but I read the issues here so often(due to mentioning). Maybe I should start contribute here.
Issue opened and closed within 6 hours. New record? 🎉