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 ActivityUnitTestCase
, since the tests will be dependent upon the Context
-object.
The package name of the main module is nilzor.myapp
. The pacakge name of the test module is nilzor.myapp.tests
Why is not the test runner detecting the testBlah()
-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="http://schemas.android.com/apk/res/android"
package="nilzor.myapp.tests"
android:versionCode="1"
android:versionName="1.0">
<!-- 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. -->
<application>
<uses-library android:name="android.test.runner"/>
</application>
<!--
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:targetPackage="nilzor.myapp"
android:label="Tests for nilzor.myapp"/>
</manifest>
And here is my test class:;
package nilzor.myapp.tests;
public class NilzorSomeTest<T extends Activity> extends ActivityUnitTestCase<T>{
public NilzorSomeTest(Class<T> activityClass){
super(activityClass);
}
@SmallTest
public void testBlah(){
assertEquals(1,1);
}
}
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:
- Do I need an Annotation above the Unit test method?
- Do I need to prefix the method with "test", or is that just for JUnit tests?
- Can I have tests in sub-packages of
nilzor.myapp.tests
?
But the main question of this post is why does not the test runner detect my test?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…