Why is the Android test runner reporting "Empty test suite"?

If this is happening "all of a sudden" or "it was working 5 minutes ago" my solution was to go into Run/Debug configurations and remove any configurations under "Android Tests". Sometimes these configurations get corrupted if I refactor the class under test (for example by moving to an new package).

enter image description here


None of the above fixed it for me. What helped was following the instructions:

Create a test configuration

In Android Studio:

  • Open Run menu -> Edit Configurations
  • Add a new Android Tests configuration
  • Choose a module
  • Add a specific instrumentation runner:

  android.support.test.runner.AndroidJUnitRunner

Run the newly created configuration.


You need to provide default constructor for your test class, for example:

package nilzor.myapp.tests;

public class NilzorSomeTest extends ActivityUnitTestCase<ActivityYouWantToTest>{
    public NilzorSomeTest(){
        super(ActivityYouWantToTest.class);
    }

    @SmallTest
    public void testBlah(){
        assertEquals(1,1);
    }
}

about your other questions:

  1. No. My tests still run without any annotations, but I guess it's a good practice to have them. It allows you to specify size of tests to run. See What is the purpose of @SmallTest, @MediumTest, and @LargeTest annotations in Android? for more detail.

  2. Yes, you need "test" prefix. InteliJ gives "method never used" warning when there's no "test" prefix, and skips that method during test run.

  3. Yes. I have my tests organized into subpackages and it seems to be working well.