- Menifest.xml中加入:
<application>中加入:
<uses-library android:name="android.test.runner" />
<application>外面加入:
<uses-permission android:name="android.permission.RUN_INSTRUMENTATION" />
<instrumentation android:name="android.test.InstrumentationTestRunner" android:targetPackage="name.feisky.android.test"
android:label="Test for my app"/>
- 编写单元测试代码:必须继承自AndroidTestCase类
package name.feisky.android.test;
import android.test.AndroidTestCase;
import junit.framework.Assert;
public class MyTest extends AndroidTestCase {
private static final String Tag="MyTest";
Android如何进行单元测试
时间: 2024-11-05 20:29:56