1.1) Create a new source folder called "Test"
1.2) Create a subclass that either extends either "TestCase" or "AndroidTestCase"*
1.3) All method should be named like "public void testX()" where "X" is whatever you want.
1.4) In the manifest you need to add:
<instrumentation
android:name="android.test.InstrumentationTestRunner"
android:targetPackage="<application_package" >
</instrumentation>
If you are going to user "AndroidTestCase" you will also have to add:
<uses-library android:name="android.test.runner" />
*AndroidTestCase is useful when you need to test something that uses the context.
1.5) Create a class that extends TestSuite as follows:
import android.test.suitebuilder.TestSuiteBuilder;
import junit.framework.Test;
import junit.framework.TestSuite;
public class AllTests extends TestSuite {
public static Test suite() {
return new TestSuiteBuilder(AllTests.class).includeAllPackagesUnderHere().build();
}
}
No hay comentarios:
Publicar un comentario