Android單元的junit測驗

1、添加配置資訊

<!-- 使用Android測驗包 -->
<uses-library android:name="android.test.runner" />

<!-- 使用android測驗包 -->
<instrumentation
android:name="android.intent.InstrumentationTestRunner"
android:targetPackage="com.itzheng.app04_sqlite" >
</instrumentation>
2、撰寫測驗類

package com.itzheng.app04_sqlite.test;
import com.itzheng.app04_sqlite.BlackNumber;
import com.itzheng.app04_sqlite.BlackNumberDao;
import android.test.AndroidTestCase;
/*
* BlackNumberDao的單元測驗類
*/
public class BlackNumberDaoTest extends AndroidTestCase {
public void testAdd(){
//創建dao物件
BlackNumberDao dao = new BlackNumberDao(getContext());
//呼叫方法
dao.add(new BlackNumber(-1,"456"));
}
}
3、啟動測驗類

運行成功

轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/259506.html
標籤:其他
上一篇:#Android Day2
