Android:JUnit
lastmod 2018-08-17created 2015-10-265 edits
Describes how to test with JUnit on Android.
Testing a regular class
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);
}
}
Testing an Android Activity
This section describes how to test the Main class (which extends 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
- Translation: Android testing - Testing and Instrumentation
- Original:
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
- Original:
Pages that link here