7

I have created a new project in Android Studio 3.2. Without making any changes I am not able to run all the unit tests in the group. I receive and error saying No tests were found

No tests were found

I am attempting to run the tests by right clicking on the group and clicking Run Tests.

I can run the unit tests if I open up the file and click on the run button next to the class declaration. I can also run the unit tests if I open the project in Android Studio 3.1.4. I can right click on the group and run all the unit tests with no error.

enter image description here

jkistler
  • 786
  • 5
  • 11

3 Answers3

5

Looking at this bug report, I think it should be fixed in 3.2.1: https://issuetracker.google.com/issues/115708445#comment12

Benoit
  • 1,168
  • 8
  • 16
0

After spending an entire day trying resolve this while writing some unit tests I found one workaround that works for my project.

Basically what my workaround is to add Build to the Before launch options. enter image description here

After adding this option I'll occasionally get the No tests found error message but simply rerunning the test worked every time after adding that setting.

I'm not sure if it will help with everyone's problem but it seems to have mitigated the issue with my project. Hopefully this works for someone else as well.

wchristiansen
  • 436
  • 7
  • 20
  • @Benoit I also had luck with using running the tests in Debug mode with at least one break point set somewhere in any test. Before using the `Build` fix I was using `Invalidate Caches / Restart` pretty much constantly to get the tests to run properly. – wchristiansen Oct 02 '18 at 15:27
  • I think I'll just wait for Google to fix their IDE and run tests through the CI/CL for now ¯\_(ツ)_/¯ – Benoit Oct 03 '18 at 08:57
0

The workaround until the bug is fixed is running tests in terminal, just type: ./gradlew test or ./gradlew testDebugUnitTest. If you are using Windows replace ./gradlew with gradlew.bat. You can also download Android Studio 3.3 Canary from here https://developer.android.com/studio/preview/ – there aren't problems with running tests via this version.

Wojtek Okoński
  • 448
  • 1
  • 4
  • 12