13

I'd like to start generating unit test code coverage reports for my Android application, where the unit tests are not in the androidTest folder, but in a test folder that I've created. To start, I've added the following to my build.gradle file:

buildTypes {
    ...
    debug {
        debuggable true
        testCoverageEnabled true
    }
    ...
}

Running ./gradlew createDebugCoverageReport generates reports for my tests in the androidTest folder, but nothing in the test folder. How can I create those same coverage reports for the tests in the test folder?

1
  • 4
    Did you find a solution to that problem ? I have the same problem and I was about to investigate it further ? If by chance you found something in-between... Commented Dec 15, 2016 at 9:35

1 Answer 1

8

I've founded answer here https://stackoverflow.com/a/23965581/1775228 Basically, you add to your gradle file:

debug {
    testCoverageEnabled true
}

and

android {
    jacoco {
        version = '0.7.9'
    }
}

After that run

./gradlew createDebugCoverageReport

in terminal and report will be generated in

/build/reports/coverage/debug

in your app folder/module. It worked for me.


For latest version and updates regarding changes read The JaCoCo Plugin.

Sign up to request clarification or add additional context in comments.

2 Comments

This is just about generating code coverage report, it did not solve the question asked.
I still only see the androidTest folder and not the one for unit tests

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.