zoukankan      html  css  js  c++  java
  • Adnroid单元测试

    1.进行单元测试需要在Manifest.xml文件里添加如下内容:

    (1)在application内添加

    <uses-library android:name="android.test.runner"/>

    (2)在application外添加

    <instrumentation 
    android:name="android.test.InstrumentationTestRunner"
    android:targetPackage
    ="com.archermind.activity"
    android:label
    ="test by kelei"
    />

    其中android:targetPackage="com.archermind.activity"要于manifest里的package="com.archermind.activity"一致

    2.建立单元测试类,单元测试类继承AndroidTestCase类

    public class StudentDAOTest extends AndroidTestCase
    {

    private static final String TAG = "StudentDAOTest";

    public void testAdd()
    {
    StudentDAO studentDAO = new StudentDAO(this.getContext());
    Student student = new Student(1, "kelei");
    studentDAO.add(student);
    Log.i(TAG, "add success");
    }

    public void testUpdate()
    {
    fail("Not yet implemented");
    }

    public void testFind()
    {
    StudentDAO studentDAO = new StudentDAO(this.getContext());
    Student student = studentDAO.find(1);
    if(student==null)
    {
    Log.i(TAG, "not find");
    }
    else
    {
    Log.i(TAG, student.toString());
    }
    }
    }




  • 相关阅读:
    TCP拥塞控制算法 — CUBIC的补丁(二)
    TCP拥塞控制算法 — CUBIC的补丁(四)
    Class chart
    Class array
    Bool to int
    using in the function
    unsafe
    resources contain {0}
    Using Nullable Types
    Microsoft.Ink namespace
  • 原文地址:https://www.cnblogs.com/kelei12399/p/2341433.html
Copyright © 2011-2022 走看看