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下的单元测试)的全部内容,更多相关adnroid(10)(android下内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复