1.冒烟测试:
adb shell monkey -p <程序的包名> -v <事件的数量>
2.android下单元测试:
在manifest节点下添加:
<instrumentation
android:name="android.test.InstrumentationTestRunner"
android:targetPackage="com.itheima.junittest" />
在application节点下配置下面信息:
<uses-library android:name="android.test.runner" />
测试的时候定义一个类继承自AndroidTestCase
android下的测试:
public class MathUtils {
/**
* 加法运算
* @param x
* @param y
* @return
*/
public static int incrment(int x, int y) {
System.out.println(x + " + " + y + " = " + (x + y));
System.err.println(x + " + " + y + " = " + (x + y));
Log.v("MathUtils", "黑色: " + x + " + " + y + " = " + (x + y));
Log.d("MathUtils", "蓝色: " + x + " + " + y + " = " + (x + y));
Log.i("MathUtils", "绿色: " + x + " + " + y + " = " + (x + y));
Log.w("MathUtils", "黄色: " + x + " + " + y + " = " + (x + y));
Log.e("MathUtils", "红色: " + x + " + " + y + " = " + (x + y));
return x + y;
}
public class Test extends AndroidTestCase {
public void test() {
// System.out.println("test is calling!!");
int result = MathUtils.incrment(9, 10);
// 断言, 断定某一个对象就是某一个值
assertEquals(19, result);
}
建工程的时候就建一个Android test Project。写下测试工程的包名就不必在配置文件中添加代码了。
adnroid(10)(android下的单元测试)
最新推荐文章于 2023-03-28 20:45:48 发布