Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Class not found: Empty test suite when running unit tests in Android Studio

I have a test suite for my Android app, and all unit tests run fine. However, whenever I make a single change in one of my unit test classes (for example, ModelUnitTests), when trying to run that class again, I get this message

Process finished with exit code 1
Class not found: "xxx.xxxxxx.xxx.ModelUnitTests"Empty test suite.

If I do a gradle clean and then run the class tests again, it runs fine (but it takes 4 minutes to do...), but then a new change will break it again.

Any advice on how to fix this? I'm not exactly sure which test configuration should I post. I'm using the Unit Tests artifact and my tests are located on the module/src/test/package folder

like image 368
Koitt Avatar asked Jun 27 '16 14:06

Koitt


2 Answers

I had a similar problem and it was because I first created an Unit Test with the same class name. When I created the Instrumented Unit Test I got the error.

To solve it, I went to Edit Configurations, on the left of the run icon. Then below Unit Test, it was the 'conflicting' class, which I deleted. Click on Apply/Ok. Then I right click on the class name, click on run and voilà, it works.

like image 87
RobertoAllende Avatar answered Nov 20 '22 02:11

RobertoAllende


The fix on Android Studio is:

  • step 1.- Go to Run/Debug configuration
  • step 2.- Go to Android Tests section
  • step 3.- Remove the test configuration file with (-)
  • step 4.- Press Apply and OK
  • step 5.- Run the test again
like image 23
Jhonny Ramirez Zeballos Avatar answered Nov 20 '22 03:11

Jhonny Ramirez Zeballos