04 - Android单元测试

来源:互联网 发布:洛氏霍克指标源码 编辑:程序博客网 时间:2024/05/01 14:28



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("");  对应警告 


0 0
原创粉丝点击