Jacoco with jUnit 4 and jUnit5

44 views
Skip to first unread message

Wahyu Permadi

unread,
Oct 9, 2020, 9:08:53 AM10/9/20
to JaCoCo and EclEmma Users
Hello, I want to ask, how to setup jacoco with an android test that running on Junit 4 and 5 ? 
ex: I have 2 unit test files
UserViewModelTest => run with jUnit 4
MemberViewModelTest => run with jUnit 5 (Using spek framework)

when I run ./gradlew testDebugUnitTest its work fine
but when I run with ./gradlew jacocoTestReport its run unit test on all build variant, 


Wahyu Permadi

unread,
Oct 9, 2020, 9:15:40 AM10/9/20
to JaCoCo and EclEmma Users

this is my jacoco setup 
https://pastebin.com/twUNzNXc

i have declare the test depends on  ":feature_response_api:testReleaseCandidateDevUnitTest"
but I don't know why, if I run the test through ./gradlew jacocoTestReport it will run with all the build variant
example ":feature_response_api:testDebugUnitTest", ":feature_response_api:testReleaseCandidateStagingUnitTest"

but if I run with ./gradlew :feature_response_api:testReleaseCandidateDevUnitTest its work fine

Evgeny Mandrikov

unread,
Oct 9, 2020, 9:43:55 AM10/9/20
to JaCoCo and EclEmma Users
On Friday, October 9, 2020 at 3:15:40 PM UTC+2 wahyu.pe...@gmail.com wrote:

this is my jacoco setup 
https://pastebin.com/twUNzNXc

i have declare the test depends on  ":feature_response_api:testReleaseCandidateDevUnitTest"
but I don't know why, if I run the test through ./gradlew jacocoTestReport it will run with all the build variant

Probably because Gradle task jacocoTestReport depends on the tasks to build all variants.
Please refer to the Gradle documentation or Gradle community/support about how to manage dependencies between tasks.

Wahyu Permadi

unread,
Oct 9, 2020, 10:20:23 AM10/9/20
to jac...@googlegroups.com
but its happen when running junit5, if only run junit 4 task its work fine..

--
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 jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/a4664525-ec49-4b3f-96b9-4fae48ea982an%40googlegroups.com.

Evgeny Mandrikov

unread,
Oct 9, 2020, 11:39:02 AM10/9/20
to JaCoCo and EclEmma Users
On Friday, October 9, 2020 at 4:20:23 PM UTC+2 wahyu.pe...@gmail.com wrote:
but its happen when running junit5, if only run junit 4 task its work fine..
 
As you can see on page https://www.jacoco.org/jacoco/trunk/doc/integrations.html integration with Gradle is third-party and not developed by developers of JaCoCo.
Both, tasks for the execution of JUnit5 and jacocoTestReport, are implemented in Gradle project (https://github.com/gradle/gradle), not in JaCoCo project (https://github.com/jacoco/jacoco
So once again: please refer to the Gradle documentation or Gradle community/support about the behavior you observe.
Reply all
Reply to author
Forward
0 new messages