manifest中:
。。。
<uses-library android:name="android.test.runner" />
</application>
<uses-sdk android:minSdkVersion="8" />
<instrumentation
android:label="test my app"
android:name="android.test.InstrumentationTestRunner"
android:targetPackage="cn.itcast.app" />
</manifest>
public class PersonServiceTest extends AndroidTestCase {
public void testSave() throws Exception{
PersonService ps =new PersonService();
ps.save(null);
}
public void testAdd() throws Exception{
PersonService ps =new PersonService();
Assert.assertEquals(3, ps.add(1, 2));
}
}
日志打印 logcat
public class PersonServiceTest extends AndroidTestCase {
public void testLogOut() throws Throwable{
//Log.i("123", "你么");
System.out.println("sdf你没");
}
System.out.println("sdf你没"); 对应info
06-12 12:12:02.521: I/ System.out(738): sdf你没
System.err.println(""); 对应警告