Android:JUnit
안드로이드에서 JUnit으로 테스트하는 방법에 대하여 설명한다.
일반적인 클래스 테스트
public class FirstJunitTest extends AndroidTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
}
@Override
protected void tearDown() throws Exception {
super.tearDown();
}
/** JUNIT Library 테스트. */
public void testPrecondition() {
assertEquals(true, true);
}
}
안드로이드 Activity 테스트방법
여기에서는 Main클래스(android.app.Activity를 상속받은)를 테스트하는 방법에 대하여 설명한다.
public class MainTest extends ActivityUnitTestCase<Main> {
private Intent mStartIntent;
public MainTest() {
super(Main.class);
}
@Override
protected void setUp() throws Exception {
super.setUp();
mStartIntent = new Intent(Intent.ACTION_MAIN);
}
@MediumTest
public void testPrecondition() {
Log.d("MainTest", "ActivityUnitTestCase test");
}
}
See also
Favorite site
Tutorials
- 번역: 안드로이드 테스트 - Testing and Instrumentation
- 원문:
https://developer.android.com/guide/topics/testing/testing_android.html - Testing and Instrumentation: Android_testing_and_instrumentation.pdf
- Testing in Eclipse, with ADT: Android_testing_in_eclipse_with_adt.pdf
- Testing in Other IDEs: Android_testing_in_other_ides.pdf
- Hello, Testing: Android_hello_testing.pdf
- Activity, Testing #1: Android_activity_testing_1.pdf
- Activity, Testing #2: Android_activity_testing_2.pdf
- 원문: