IntelliJ / Android가 "Empty test suite"를보고하는 이유를 알아 내려고 여기 벽에 머리를 부딪 히고 있습니다. 두 개의 IntelliJ 모듈 (Eclipse의 "Projects")이있는 작은 프로젝트가 있습니다. 단위 테스트 모듈에는 맨 아래에 붙여 넣은 자체 AndroidManifest.xml이 있습니다. ActivityUnitTestCase테스트가 Context-object에 의존하기 때문에을 실행하려고합니다 .
기본 모듈의 패키지 이름은입니다 nilzor.myapp. 테스트 모듈의 pacakge 이름은 다음과 같습니다.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);
}
}
이클립스 용 임에도 불구 하고 테스트 기본 사항 , 활동 테스트 문서를 읽고이 Hello world 테스트 블로그를 따라가 보았습니다 . 테스트 러너가 내 테스트를 찾아 실행할 수 없습니다. 내가 뭘 잘못하고 있죠?
여전히 확신 할 수없는 몇 가지 질문은 다음과 같습니다.
- 단위 테스트 방법 위에 주석이 필요합니까?
- 메소드 앞에 "test"를 붙여야합니까, 아니면 JUnit 테스트 전용입니까?
- 의 하위 패키지에서 테스트를 할 수 있습니까
nilzor.myapp.tests?
그러나이 게시물의 주요 질문은 테스트 러너가 내 테스트를 감지하지 못하는 이유입니다 .
@Test테스트 상단에 마커 를 놓는 것을 잊지 않았는지 확인하십시오 .

cmd+shift+t를 사용하는 경우 현재 편집중인 클래스와 일치하는 올바른 패키지 위치에 테스트 클래스를 자동으로 생성하는 바로 가기를 권장합니다 .