Nilzor Nilzor - 1 year ago 64
Android Question

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

I am banging my head against the wall here trying to figure out why IntelliJ/Android is reporting "Empty test suite". I have a small project with two IntelliJ Modules ("Projects" in Eclipse). The Unit test module has its own AndroidManifest.xml, which I have pasted at the bottom. I am trying to run an

, since the tests will be dependent upon the

The package name of the main module is
. The pacakge name of the test module is

Why is not the test runner detecting the
-method as a test?

<?xml version="1.0" encoding="utf-8"?>
<!-- package name must be unique so suffix with "tests" so package loader doesn't ignore us -->
<manifest xmlns:android=""
<!-- We add an application tag here just so that we can indicate that
this package needs to link against the android.test library,
which is needed when building test cases. -->
<uses-library android:name="android.test.runner"/>
This declares that this application uses the instrumentation test runner targeting
the package of nilzor.myapp. To run the tests use the command:
"adb shell am instrument -w nilzor.myapp.tests/android.test.InstrumentationTestRunner"
<instrumentation android:name="android.test.InstrumentationTestRunner"
android:label="Tests for nilzor.myapp"/>

And here is my test class:;

package nilzor.myapp.tests;

public class NilzorSomeTest<T extends Activity> extends ActivityUnitTestCase<T>{
public NilzorSomeTest(Class<T> activityClass){

public void testBlah(){

I have read the testing fundamentals, the activity testing document, and tried following this Hello world test blog, even though it is for Eclipse. I cannot get the test runner to find and run my test. What am I doing wrong?

Some of the questions I still feel unsure about are:

  1. Do I need an Annotation above the Unit test method?

  2. Do I need to prefix the method with "test", or is that just for JUnit tests?

  3. Can I have tests in sub-packages of

But the main question of this post is why does not the test runner detect my test?

Answer Source

I just started learning about testing Android applications and I've been struggling with the same problem. You need to provide default constructor for your test class, for example:

package nilzor.myapp.tests;

public class NilzorSomeTest extends ActivityUnitTestCase<ActivityYouWantToTest>{
    public NilzorSomeTest(){

    public void testBlah(){

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.