Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run tests with coverage in Android Studio 2.3

In the new version of Android Studio, 2.3 Canary, I no longer have the "Run with Coverage..." option for tests.

Does anyone know if the option was somehow integrated into another mechanism, or was it removed altogether?

I hope not, that would be really bad, as I strongly relied on it when doing TDD with Robolectric :-( While the option to put a picture in the editor background is nice - having a cat stare at me for 8h is cool - not getting coverage reports is a rather high price to pay... :-(

like image 648
Kelevandos Avatar asked Nov 16 '16 14:11

Kelevandos


People also ask

How to check test coverage in android studio?

View test coverage To run tests with coverage, follow the same steps as described in Run tests, only instead of clicking Run , click Run test-name with coverage . In the Project window, this option might be hidden behind More Run/Debug.

What is run app with coverage Android studio?

Android Studio has a built-in feature that allows you to run tests with code coverage. Simply navigate to the src/test/java folder and right click. Then select Run 'Tests in 'java'' with Coverage (awkward use of single quotes theirs not mine).

How do I create a test folder in Android?

To add a testing source set for your build variant in Android Studio, follow these steps: In the Project window on the left, click the drop-down menu and select the Project view. Within the appropriate module folder, right-click the src folder and click New > Directory.

What is testing in Android?

Testing is an integral part of the app development process. By running tests against your app consistently, you can verify your app's correctness, functional behavior, and usability before you release it publicly. You can manually test your app by navigating through it.


1 Answers

The option is back in Android Studio 2.3 Canary 3! :D


EDIT:

However, it seems broken :-( After running it once the IDE decided to say I have no tests in the suite :-(

However, there is a way to enable it in 2.3.2:

  1. Download 2.3.3., open the archive, go to folder named plugin, then to coverage and copy the BUILD file you will find in there.
  2. Go to your 2.3.2. installation, and also open plugin and then coverage (the plugin was in 2.3. all the time, just inactive!)
  3. Paste the BUILD file here and start Android Studio 2.3.2. You should now have access to Run with Coverage option :-D
like image 90
Kelevandos Avatar answered Oct 17 '22 16:10

Kelevandos