Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No Tests Found Android Studio 3.2

Right clicking on a package and selecting Run Tests... results in the message No tests were found. In earlier versions of Android Studio my tests were found and would run using this method. Running test classes individually seems to work still. I've tried Invalidate Cache / Restart, but still running into the same issue.

Logs:

---- IntelliJ IDEA coverage runner ---- 
sampling ...
include patterns:
exclude patterns:0 test classes found in package '<default package>'

Process finished with exit code 254
Empty test suite.

Any point in the right direction would be appreciated. Thanks!

like image 419
Aidan Laing Avatar asked Sep 28 '18 23:09

Aidan Laing


1 Answers

I've seen this happen when AS tries to run unit tests (test/ folder) instead of instrumentation tests (androidTest/ folder) or the package specification for the configuration is wrong.

  1. Make sure that when you right click a folder to run the package of tests, and select "Run", that the icon has a little droid on it to indicate it's treating the folder as android tests:

    enter image description here

    If it doesn't, continue to step 2. If it does, skip to step 3.

  2. Sometimes AS gets confused and thinks Android tests are unit tests. To fix that, click the Run Configuration icon in the toolbar and select "Edit Configurations..."

    enter image description here

    You should see an option for Android Tests:

    enter image description here

    Select this and copy that configuration, then on the right, change it from "All in Module" to "All in Package"

  3. Make sure the configuration for the package tests specifies the full package you want to test:

    enter image description here

Once your configuration is correctly set up to run Android tests and explicitly indicate the full and correct package of tests to run, it should work.

Hope that helps!

like image 149
dominicoder Avatar answered Dec 02 '22 19:12

dominicoder