1

I have most of the test of my project in the AndroidTest folder instead of Test because they need to use a lot of Db methods and because my colleagues decided to put them there. Now I can't move them because they'll stop working. But I need to get the code coverage of said tests...

Is there any way to enable code coverage for test under AndroidTest folder? I've been looking but none of the solutions I found work for me.

Note that I also have some Espresso tests that I'd like to get coverage to if it is possible.

10
  • I wrote an article about this: github.com/uriel-frankel/android-code-coverage Commented Jan 14, 2018 at 11:45
  • @UrielFrankel Hey thanks for the help, but I got stuck at trying to pull the coverage.ec file. It says it doesn't exist even tho I just copied and pasted the 'generated code coverage data to' filepath Commented Jan 14, 2018 at 13:32
  • you meant adb pull /data/user/0/com.hellojacoco.app/files/coverage.ec ? Commented Jan 14, 2018 at 13:58
  • Yes, it says adb: error: remote object 'data/user/0/com.patan.gimnasio/files/coverage.ec' does not exist Commented Jan 14, 2018 at 14:41
  • @UrielFrankel do you know why? Commented Jan 15, 2018 at 9:33

1 Answer 1

3

I got a simple command for you.

./gradlew createDebugCoverageReport

I just found out about this myself. The one problem is that it won't display anything in the Android Studio IDE, which is annoying, and I'm currently looking for a solution to. Instead, it'll instead create a JaCoCo report in the /app/build/reports/coverage/debug/ folder. I don't know if this'll also pick up espresso tests because I haven't messed with those yet.

Anyway, hope that helped.

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

3 Comments

The system cannot find the file specified
"gradlew createDebugCoverageReport" worked from the run anything (ctrl-ctrl) window
That folder does not exist after I ran the command

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.