[英]How to Generate Android Testing Report in HTML Automatically
I would like to automatically generate unit testing report in html format for Android application on Hudson continuous integration server.我想在 Hudson 持续集成服务器上为 Android 应用程序自动生成 html 格式的单元测试报告。
Therefore, I try to run test cases first and gather test result files in xml format.因此,我尝试先运行测试用例并收集 xml 格式的测试结果文件。 Then, I use JUnitReport Task to transform the XML result files into HTML format.
然后,我使用 JUnitReport Task 将 XML 结果文件转换为 HTML 格式。
I run test cases through Android instrumentation framework.我通过 Android 仪器框架运行测试用例。 However, it only provides verbose output information rather than the standard JUnit XML format.
但是,它只提供详细的 output 信息,而不是标准的 JUnit XML 格式。 I have no idea how to generate HTML unit test report without JUnit XML result files.
我不知道如何在没有 JUnit XML 结果文件的情况下生成 HTML 单元测试报告。
If I run test cases using Eclipse, it can export results in XML files with time consumed information per test case.如果我使用 Eclipse 运行测试用例,它可以将结果导出到 XML 个文件中,其中包含每个测试用例的耗时信息。 Those XML files can be transformed into HTML by JUnitReport Task correctly.
那些 XML 文件可以通过 JUnitReport 任务正确转换为 HTML。 As a result, it seems that it is possible to collect the test result with time consumed information.
结果,似乎可以收集带有时间消耗信息的测试结果。
Is there any way to get the standard JUnit XML result file automatically after running test cases on Android instrumentation framework?在Android仪器框架上运行测试用例后,有没有办法自动获取标准JUnit XML结果文件?
We had similar problem in our company. 我们公司也有类似的问题。 We checked all the available open-source solutions and none of them was really perfect.
我们检查了所有可用的开源解决方案,但没有一个是非常完美的。 So we developed and just open-sourced a solution for it.
所以我们开发并开发了一个解决方案。 I still do not say an "ultimate" one but certainly much better than either athena or the python reporter or any after-test analysis.
我仍然没有说“终极”,但肯定比雅典娜或蟒蛇记者或任何后测试分析要好得多。 You can find it here: http://code.google.com/p/the-missing-android-xml-junit-test-runner/
您可以在此处找到它: http : //code.google.com/p/the-missing-android-xml-junit-test-runner/
It provides: 它提供:
Instead of analysing java source code (as in athena) or analysing the output (the python script), we extended android instrumentation runner. 我们扩展了android instrumentation runner,而不是分析java源代码(如在athena中)或分析输出(python脚本)。 So we get all the benefits of using standard command line options for test selection, coverage enabling etc. - all described here: http://developer.android.com/guide/developing/testing/testing_otheride.html#RunTestsCommand .
因此,我们可以获得使用标准命令行选项进行测试选择,覆盖启用等所有好处 - 所有这些都在此处描述: http : //developer.android.com/guide/developing/testing/testing_otheride.html#RunTestsCommand 。
We were able to successfully run the code using standard test rules with coverage analysed by emma, all nicely reported in Jenkins. 我们能够使用标准测试规则成功运行代码,并使用emma分析覆盖范围,所有这些都在Jenkins中得到了很好的报道。
I don't think it is possible, so you need to create a utility that converts the Android test runner output into JUnit-format XML files. 我不认为这是可能的,因此您需要创建一个将Android测试运行器输出转换为JUnit格式XML文件的实用程序。
However, you won't be able to get the time-per-test value, as the Android test runner doesn't seem to output that information. 但是,您将无法获得每次测试的时间值,因为Android测试运行器似乎不会输出该信息。
I think the athena approach is the lest painfull as you can simply install the athena jar file on your system and add following ant target 我认为athena方法是最痛苦的,因为你可以简单地在你的系统上安装athena jar文件并添加以下ant目标
<property name="junit.dir" value="${basedir}/junit-results"/>
<property name="athena.jar" value="/home/cruise/athena/athena-1.1.2.jar"/>
<target name="prepare" description="Setup needed directories">
<mkdir dir="${junit.dir}"/>
</target>
<!-- This target will compile/install tested project as well as test project to ensure tests are executed against latest code -->
<target name="athena" depends="prepare, -install-tested-project, install" description="Run tests and convert result to xml using athena">
<exec executable="java" os="Linux" failonerror="true">
<arg value="-cp"/>
<arg value="${athena.jar}"/>
<arg value="com.synaptik.athena.Athena"/>
<arg value="${basedir}"/>
<arg value="${junit.dir}/TEST-result.xml"/>
</exec>
</target>
From command line it is then simply a matter of running ant athena and you have the test result in xml. 从命令行开始,只需运行ant athena就可以得到xml中的测试结果。 This will also be the target your CruiseControl script should trigger.
这也是您的CruiseControl脚本应该触发的目标。
I'm in a similar situation and found https://docs.marathonlabs.io/ works great for my use case.我处于类似情况,发现https://docs.marathonlabs.io/非常适合我的用例。 Other options I've looked into:
我研究过的其他选项:
adb shell am instrument -f <proto_file>
to store the instrumentation result in a protobuf file, read it in and convert it to junit xml file.adb shell am instrument -f <proto_file>
将检测结果存储在 protobuf 文件中,将其读入并转换为 junit xml 文件。 Looking at the Android instrument source code for am/instrument.java
, it seems the testlevel runtime are kept when we run it with -f instead of -r.am/instrument.java
的Android 仪器源代码,当我们使用 -f 而不是 -r 运行它时,似乎保留了测试级运行时。 But this means we will have to create our own protobuf parser file to generate the Junit-style XML file yourself.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.