Android 使用JUnit进行单元测试

打开AndroidManifest.xml文件,在</activity>下面添加这一行:
<uses-library android:name="android.test.runner"/>
 

在</application>下面添加这一行:(把 com.example.readwritexml 改为你待测试的程序包名)

<instrumentation android:name="android.test.InstrumentationTestRunner" android:targetPackage="com.example.readwritexml" android:label="Tests for My App" />

 新一个测试类,继承自 android.test.AndroidTestCase,就可以写测试方法了。

原文地址:https://www.cnblogs.com/jxgxy/p/2609198.html