0

I try to get code coverage using Jacoco in Android Studio. When I write @SmallTest and enter

$./gradlew createDebugCoverageReport

it gives me coverage perfectly. It is created in

build/outputs/reports/coverage/debug/index.html

and test report is in ;

build/outputs/reports/androidTests/connected/index.html

When I add plugin Junit4 in gradle.build file , change the @SmallTest annotation to @Test and enter

   '$./gradlew test'

it runs the tests and gives me the results in different directory which is ;

build/test-report/index.html

But when I run createDebugCoverageReport in this case (with JUnit 4) coverage is empty and test report says there is no test, first directory I mention about (build/outputs/reports/androidTests/connected/index.html). But in the second directory (build/test-report/index.html) I can see that my tests are exist and passed.

Before you ask after every execution I run;

'$./gradlew clean'

to be sure there is no leftover reports.

I add the directory screenshoots below .

Anyone have a suggestion. How do I run JUnit4 and Jacoco together ?

P.S : Sorry for my english it is not my native language. Images : Without Junit4 plugin http://s28.postimg.org/7dj9kdk31/Screen_Shot_2014_11_18_at_19_01_41.png

http://s9.postimg.org/4v9qsx9vj/Screen_Shot_2014_11_18_at_19_01_57.png

emin deniz
  • 439
  • 5
  • 13
  • AFAIK Junit4 is not supported at the moment. – rciovati Nov 18 '14 at 17:31
  • 1
    I found a solution. The main problem is I should define testClass to gradle. Thanks to this guy answer ; http://stackoverflow.com/questions/18358297/android-test-code-coverage-with-jacoco-gradle-plugin – emin deniz Nov 19 '14 at 15:44

0 Answers0