I hope someone can help me with the following problem:
*(I know my project uses the Jacoco Gradle plugin and this mail group is
only for Jacoco, but maybe I'm just doing something wrong regarding Jacoco
in general)*
*Environment:*
An Android project that uses Jacoco (through Gradle), this project has both
normal unit tests and integration tests using the Android Instrumented
Runner.
I have two modules:
- Module A contains tests (both unit tests and android instrumented
tests) some of these tests touch code in module B
- Module B contains tests (both unit tests and android instrumented
tests), it also contains code that is only touched by tests in module A
Module A depends on module B.
I configured Jacoco to use multiple `.exec` files, 4 in total:
- Module A .exec file from the unit tests
- Module A .exec file from the android instrumented tests (downloaded
from device)
- Module B .exec file from the unit tests
- Module B .exec file from the android instrumented tests (downloaded
from device)
I also made sure Jacoco uses all class files (from both modules) and all
sources (from both modules)
I tried Jacoco : 8.2, 8.4 and 8.5
*Result:*
- Code in module A, touched by unit tests in module A show as covered ✔
- Code in module A, touched by android instrumented tests in module A
show as covered ✔
- Code in module B, touched by unit tests in module B show as covered ✔
- Code in module B, touched by android instrumented tests in module B
show as covered ✔
aggregate expectations:
- Code in module B, touched by unit tests in module A show as covered ❌
- Code in module B, touched by android instrumented tests in module A
show as covered ✔
[image: sample.png]
Notice how "touchedByUnitTestInConsumer()" is not covered even though the
test reaches this code (I tested this by adding an exception).
*Expected result:*
- Code in module B, touched by unit tests in module A show as covered ✔
*The problem:*
Everything seems to work except for code in module B that is touched by
unit tests in module A, that code does not show up as "covered". Which I
find weird because it does work for the "android instrumented tests".
*Things I tried:*
I tried to instead of configuring Jacoco to use multiple .exec files to
merge the files into one file before feeding it into Jacoco, but the report
didn't show any difference. I also tried to use the append option to append
everything into one .exec files.
Is Jacoco even supposed to show code as covered when it is touched by tests
in another module?
Logging also seems to suggest that Jacoco is configured correctly (I have
indeed 4 sources classes, 2 in module A and 2 in module B, I also have 4
.[ex]ec files):
[ant:jacocoReport] Loading execution data file
*\multi-module\app\build\jacoco\testDebugUnitTest.exec
[ant:jacocoReport] Loading execution data file
*\multi-module\app\build\outputs\code_coverage\debugAndroidTest\connected\Pixel_2_API_27(AVD)
- 8.1.0-coverage.ec
[ant:jacocoReport] Loading execution data file
*\multi-module\library_android\build\jacoco\testDebugUnitTest.exec
[ant:jacocoReport] Loading execution data file
*\multi-module\library_android\build\outputs\code_coverage\debugAndroidTest\connected\Pixel_2_API_27(AVD)
- 8.1.0-coverage.ec
[ant:jacocoReport] Writing bundle 'multi-module' with 4 classes
*Sample project:*
I have a sample project:
https://github.com/NeoTech-Software/Android-Root-Coverage-Plugin/tree/bug/unit-test-a-no-coverage-in-b
My project is a Gradle Plugin that takes away most of the boilerplate code
that is needed to configure Jacoco for Android projects. However I added a
few extra tests to confirm everything really works, you can find these
tests in branch bug/unit-test-a-no-coverage-in-b the tests in this branch
fail due to the problem I described.
Who can shed some light on this? Thanks!
--
You received this message because you are subscribed to the Google Groups
"JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jacoco/26969401-3201-4a02-a9d6-a76f7e41c434%40googlegroups.com.