对app进行单元测试时,或使用robotium进行黑盒测试时,需要把测试apk安装到模拟器或者android真机上,然后用命令去驱动测试

1.运行测试程序命令-运行测试工程中所有test方法:

>adb shell am instrument -w 测试程序packageName/android.test.InstrumentationTestRunner

例如:
>adb shell am instrument -w com.example.action02.test/android.test.InstrumentationTestRunner

2.运行测试程序命令-运行测试工程中指定测试类方法:

>abd shell am instrument -e class package.testClass(测试类)-w packageName/android.test.InstrumentationTestRunner


例如:adb shell am instrument -e class com.example.action02.test.testlogin -w com.example.action02.test/android.test.InstrumentationTestRunner

3.运行测试程序命令-运行单个测试方法

>adb shell am instrument -e class package.testClass#testmethod-w cpackageNameandroid.test.InstrumentationTestRunner

例如:adb shell am instrument -e class com.example.action02.test.testloginandquit#testlogin -w com.example.action02.test/android.test.InstrumentationTestRunner

更多相关文章

  1. Android(安卓)Too many classes in --main-dex-list 错误原因及A
  2. AOSP和Chromium的Android(安卓)WebViewTest
  3. Android利用setLayoutParams在代码中调整布局(Margin和居中)
  4. android开发环境搭建备忘
  5. 让Android后台运行,不用service
  6. Android—— ubuntu下【CTS】测试TV真机
  7. Android(安卓)== 在Android系统上运行JAVA程序
  8. 通过终端命令生成并在手机上运行dex文件
  9. Robotium---环境搭建及入门示例

随机推荐

  1. 1 Android 安全机制概述
  2. j2me to android
  3. android 使用覆盖图
  4. 转载:Android的设置界面及Preference使用
  5. 关于Zipalign的介绍和使用方法
  6. android mainfest 属性详解
  7. Android点滴累计
  8. android后台服务service全解析(上)--serv
  9. Android(安卓)学习 之 Canvas (一)
  10. Android学习心得(二)——短信服务