右键该项目,选择property然后选择java build path, 选择 Add External JARs,选择下到的robotium.jar
在跑测试用例之前,还需要修改下AndroidManifest.xml文件的android:targetPackage为被测应用的根的包名
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.mitalk.test" android:versionCode="1" android:versionName="1.0" > <supports-screens android:anyDensity="true" /> <uses-sdk android:targetSdkVersion="17" /> <uses-sdk android:minSdkVersion="17" /> <instrumentation android:name="android.test.InstrumentationTestRunner" android:targetPackage="com.tencent.mm" /> <application android:debuggable="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <uses-library android:name="android.test.runner" /> </application> </manifest> |
以上都弄完了,run as android junit test,就可以跑了
备注:另外的运行方式:
Test can also be run using command prompt/terminal by following simple steps * Write following command to install AndroidCalculator apk on emulator > adb install <path>/AndroidCalculator.apk * Write following command to install AndroidCalculatorTest apk on emulator > adb install <path>/AndroidCalculatorTestApk.apk * Run the test cases: > adb shell am instrument -w com.testcalculator/android.test.InstrumentationTestRunner |