首页 > 移动平台 > 详细

单元测试-AndroidTestCse

时间:2015-11-18 22:59:36      阅读:410      评论:0      收藏:0      [点我收藏+]

实现步骤:

  1.创建一个class继承AndroidTestCase,在重写Test方法

    public class Test extends AndroidTestCase {
       public void Test(){
        int in=A.show(2,2);
        System.out.println(in);
       //断言:检测预期和实际的效果是否一致
        assertEquals(in,in);
      }
    }

  2.在创建一个测试类

   public class A {
       public static int show(int i,int j){
         return i+j;
     }
   }

  3.在配置文件中做好配置

   <uses-sdk
          android:minSdkVersion="8"
          android:targetSdkVersion="17" />
   <instrumentation
        android:name="android.test.InstrumentationTestRunner"

      //设置要测试的应用程序包名
        android:targetPackage="com.example.danyuanceshi">
   </instrumentation>

 

  <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <uses-library android:name="android.test.runner"/>

单元测试-AndroidTestCse

原文:http://www.cnblogs.com/Andmin/p/4976067.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!