android SQLite数据库的增删改查以及事务的单元测试
2010-11-05 00:56:30 来源:WEB开发网}
public void testSave() throws Throwable{
PersonService personservice = new PersonService(this.getContext());
Person person = new Person("张大千",29);
personservice.save2(person);
}
public void tesetUpdate() throws Throwable{
PersonService personService = new PersonService(this.getContext());
Person person = personService.find(1);
person.setName("jim");
personService.update(person);
}
public void testCount() throws Throwable{
PersonService personService = new PersonService(this.getContext());
Log.i("aa",personService.getCount()+"");
}
public void testGetScrollData() throws Throwable{
PersonService personService = new PersonService(this.getContext());
List< Person> persons = personService.getScrollData(0,3);
for(Person person:persons){
Log.i("aa",person.toString());
}
}
public void TrancesTest() throws Throwable{
PersonService personService = new PersonService(this.getContext());
Person person = new Person("aaaaaaa",28);
personService.savesTrannces(person);
}
}
AndroidManifest.xml配置文件中添加单元测试的权限:
< ?xml version="1.0" encoding="utf-8"?>
< manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.gohighsoft.db" android:versionCode="1"
android:versionName="1.0">
< application android:icon="@drawable/icon" android:label="@string/app_name">
< uses-library android:name="android.test.runner" />
< activity android:name=".MainActivity" android:label="@string/app_name">
< intent-filter>
更多精彩
赞助商链接