我是EMMA的新手,不知道如何在android系统中使用它。 请问有人可以提供一个EMMA在android上使用的示例吗? 非常感谢。
我是EMMA的新手,不知道如何在android系统中使用它。 请问有人可以提供一个EMMA在android上使用的示例吗? 非常感谢。
我只能通过Ant来使Emma工作。如果您已经设置好了Ant构建,则可以运行以下命令:
ant emma debug install
ant emma debug install test
<if condition="${emma.enabled}">
<then>
<echo>WARNING: Code Coverage is currently only supported on the emulator and rooted devices.</echo>
<run-tests-helper emma.enabled="true">
<extra-instrument-args>
<arg value="-e" />
<arg value="coverageFile" />
<arg value="${emma.dump.file}" />
</extra-instrument-args>
</run-tests-helper>
<echo>Copying coverage to readable directory...</echo>
<exec executable="${adb}" failonerror="true">
<arg line="${adb.device.arg}" />
<arg value="shell" />
<arg value="echo cp ${emma.dump.file} /sdcard/coverage.ec | su" />
</exec>
<echo>Downloading coverage file into project directory...</echo>
<exec executable="${adb}" failonerror="true">
<arg line="${adb.device.arg}" />
<arg value="pull" />
<arg value="/sdcard/coverage.ec" />
<arg value="coverage.ec" />
</exec>
<echo>Extracting coverage report...</echo>
<emma>
<report sourcepath="${tested.project.absolute.dir}/${source.dir}"
verbosity="${verbosity}">
<!-- TODO: report.dir or something like should be introduced if necessary -->
<infileset dir=".">
<include name="coverage.ec" />
<include name="coverage.em" />
</infileset>
<!-- TODO: reports in other, indicated by user formats -->
<html outfile="coverage.html" />
</report>
</emma>
<echo>Cleaning up temporary files...</echo>
<delete file="coverage.ec" />
<delete file="coverage.em" />
<echo>Saving the report file in ${basedir}/coverage/coverage.html</echo>
</then>
<else>
<run-tests-helper />
</else>
</if>
显然,EMMA目前还没有为SDK提供支持。它仅支持源代码树中的应用程序和测试。这似乎很奇怪,因为在开发指南中介绍EMMA插桩选项时,并没有提到这一点。 http://developer.android.com/guide/developing/testing/testing_otheride.html#AMOptionsSyntax
你可以阅读来自这位开发团队成员的回复(好像是?我不太确定) http://groups.google.com/group/android-developers/msg/a542afd318832371
如果你想下载并构建Android源代码,那么让EMMA为你自己的应用程序工作似乎是可行的。但这听起来有点棘手且可能不太稳定。请参阅完整的主题以获取更多信息: http://groups.google.com/group/android-developers/browse_thread/thread/43cf8a8ca5662f85/9b68eec3e7b625f3?lnk=gst&q=Emma#
http://code.google.com/p/maven-android-plugin/wiki/EmmaMaven
实施解决方案很容易,除了报告生成之外。 但是,如果您查看维基的评论,您会找到解决方案。