安卓单元测试InstrumentationTestRunner

来源:互联网 发布:windows xp软件功能 编辑:程序博客网 时间:2024/06/08 08:33

外部测试项目实现:
1、配置环境

<instrumentation        android:name="android.test.InstrumentationTestRunner"        android:targetPackage="cn.itcast.test" />    <application        android:icon="@drawable/ic_launcher"        android:label="@string/app_name" >     //////进行单元测试的包路径设置        <uses-library android:name="android.test.runner" />    </appication```2、单元测试类AndroidTestCase 

public class PersonServiceTest extends AndroidTestCase {

public void testSave() throws Exception{    PersonService service = new PersonService();    service.save(null);}public void testAdd() throws Exception{    PersonService service = new PersonService();    int actual = service.add(1, 2);    //验证测试结果--预言    Assert.assertEquals(3, actual);}

}
“`
3、通过junit的视图查看相关情况

0 0