Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio Unit Tests With Coverage Showing 0% On Everything

I'm trying to check my unit test coverage, all my tests are passing, but when I run the tests with 'Run Tests With Coverage' by right clicking on my test file, when it completes, everything comes back as 0%?

Looks like it's supposed to just work reading https://developer.android.com/studio/test/index.html and can't find anything saying why it would be returning 0% for everything?

Is there some hidden setting I'm missing to get this working?

like image 633
Ben987654 Avatar asked Mar 19 '18 04:03

Ben987654


1 Answers

Go to Run->Edit Configuration->Code coverage. Add your package/class for which you want to run tests, in Packages and classes to record coverage data section.

Also, check Enable coverage in test folders option.

Click Apply and Ok. Re-run your tests with coverage.

like image 139
Amrita Avatar answered Sep 27 '22 23:09

Amrita