Android Junit Test(semc-build编译并且生成emma coverage)

本文详细介绍了如何在Android项目中使用Emma获取覆盖率报告,包括构建目标应用、安装、运行自动化测试、提取覆盖率文件及生成报告的步骤。涉及semc-build工具和adb命令。
摘要由CSDN通过智能技术生成
========================================================
get emma coverage steps:
========================================================
1. build target app and test app:
semc-build debug-test-instr -Demma-coverage-on=true -Drun-emma=true
解决自动重启并且清除data:semc-build ci-onrunning-instr -Demma-coverage-on=true -Drun-emma=true

2. adb push target app into phone
adb push SomcChameleonWorkflow /system/priv-app/
adb push bin/SomcChameleonWorkflow.apk /system/priv-app/SomcChameleonWorkflow/
adb push semc-build-output/SomcChameleonWorkflow/bin/SomcChameleonWorkflow.apk /system/priv-app/SomcChameleonWorkflow/

3. install test app into phone
adb install -r semc-build-output/test-SomcChameleonWorkflow/bin/test-SomcChameleonWorkflow.apk 

4. run auto test(-r -e coverage true -e 生成coverage.ec文件)
adb shell am instrument -r -e coverage true -e class com.sonymobile.chameleon.workflow.FBasicSetupActivity -w com.sonymobile.chameleon.workflow.tests/android.test.InstrumentationTestRunner

adb shell am instrument -r -e coverage true -e class com.sonymobile.chameleon.workflow.FBasicSetupActivity -w com.sonymobile.chameleon.workflow.tests/com.sonymobile.chameleon.workflow.runners.FunctionalTestRunner

adb shell am instrument -r -e coverage true -e class com.sonymobile.chameleon.workflow.FBasicSetupActivity -w com.sonymobile.chameleon.workflow.tests/com.sonymobile.chameleon.workflow.runners.UnitTestRunner

5. pull out the .ec file from the phone
adb pull /data/data/com.sonymobile.chameleon.workflow/files/coverage.ec reports/coverage/

6. generate emma coverage report:
java -Xmx128m -cp ~/.semctools/emma/emma.jar emma report -r html -sp ./src -in reports/coverage/coverage.ec,reports/coverage/coverage.em

Notes:
1. 以上每一步都是在workflow的代码根目录:vendor/semc/packages/apps/chameleon/workflow$
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值