免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1626 | 回复: 0
打印 上一主题 下一主题

如何执行android junit test [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-12-22 08:51 |只看该作者 |倒序浏览
一. 用ant, 通过修改build.xml来执行
1. 首先编译test project,注意,如果没有release key,只能编译 debug版本(在eclipse下会用自签名的key签名)
2. 执行ant -p,列出可执行的target选项。到底有哪些target, 由build.xml中说明来决定的
     <!-- Required pre-setup import -->
    <import file="${sdk.dir}/tools/ant/pre_setup.xml" />   

3. 然后用ant targetname, 做相应的事情
     eg. ant debug: Builds the application and signs it with a debug key.
           ant coverage:Runs the tests against the instrumented code and generates code coverage report
   ant run-tests: Runs tests from the package defined in test.package property
4. ant coverage 可以 生成html报表,但必须在emulaotr上跑才能生成,在device上跑不能生成

二. 用adb shell am instrument命令来执行
需要借助com.zutubi.android.junitreport.JUnitReportTestRunner
The runner supports two arguments:
  * reportFilePath: the path, relative to the root of the tested
    application's file storage area, of the report file to generate.
    Defaults to junit-report.xml.
  * filterTraces: if true, stack traces in the report will be filtered
    to remove common noise (e.g. framework methods).  Defaults to
    true.
命令格式为:
adb shell am instrument -w -e reportFilePath my-report.xml \
  com.example.test/com.zutubi.android.junitreport.JUnitReportTestRunner
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP