1. Inherit androidtestcase : public class JunitTest3 extends Androidtestcase {}
2. Add the following code to the Androidmanifest.xml manifest file:
<manifest xmlns:android= "Http://schemas.android.com/apk/res/android"
Package= "com.example.showdata"
Android:versioncode= "1"
Android:versionname= "1.0" >
<instrumentation
Android:name= "Android.test.InstrumentationTestRunner"
Android:targetpackage= "com.example.showdata" >
</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"/>
<activity
Android:name= "Com.example.showdata.MainActivity"
Android:label= "@string/app_name" >
<intent-filter>
<action android:name= "Android.intent.action.MAIN"/>
<category android:name= "Android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
3. Right-click the-->run as--->android Junit test on the method you want to test, you need to open the emulator first
Android Test framework 1 (non-original)