IntelliJ /Androidが「空のテストスイート」を報告している理由を理解しようと、ここで壁に頭をぶつけています。2つのIntelliJモジュール(Eclipseでは「プロジェクト」)を含む小さなプロジェクトがあります。ユニットテストモジュールには独自のAndroidManifest.xmlがあり、これを下部に貼り付けました。テストは-objectActivityUnitTestCase
に依存するため、を実行しようとしています。Context
メインモジュールのパッケージ名はですnilzor.myapp
。テストモジュールのパッケージ名は次のとおりです。nilzor.myapp.tests
テストランナーがtestBlah()
-methodをテストとして検出しないのはなぜですか?
<?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>
そして、これが私のテストクラスです:;
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);
}
}
テストの基礎、アクティビティテストのドキュメントを読み、Eclipse用ですが、このHelloworldテストブログをフォローしてみました。テストランナーにテストを見つけて実行させることができません。私は何が間違っているのですか?
私がまだ確信が持てない質問のいくつかは次のとおりです。
- ユニットテストメソッドの上に注釈が必要ですか?
- メソッドの前に「test」を付ける必要がありますか、それともJUnitテスト専用ですか?
- のサブパッケージでテストを行うことはできます
nilzor.myapp.tests
か?
しかし、この投稿の主な質問は、なぜテストランナーが私のテストを検出しないのかということです。