【搭建Android Junit Test】
public class TESTPerson extends AndroidTestCase {
public void testCreateDB()
{
DBOpenHelper dbOpenHelper = new DBOpenHelper(getContext());
dbOpenHelper.getWritableDatabase();
Person person = new Person();
new PersonService(getContext()).save(person);
System.out.println("-----------dsdfsdfsdfsd");
}
}
--------------------------------------------------------------------------------------------------------------------------------------------
//AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"package="com.ws.person"
android:versionCode="1"
android:versionName="1.0" >
<instrumentation
android:name="android.test.InstrumentationTestRunner"
android:targetPackage="com.ws.person"></instrumentation>
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="14" />
<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" /> <activity android:name="com.ws.person.AndroidClientActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> 原文链接:https://www.f2er.com/sqlite/199485.html