简体   繁体   English

如何在运行仪器命令时生成html报告-Uiautomator

[英]how to generate html report while running am instrument command - Uiautomator

I am a beginner and using UIautomator for Android instrumentation. 我是一个初学者,并且使用UIautomator进行Android工具测试。 I am able to run tests from Android studio ( androidTest instrumentation ) and I am able to generate the report (html and xml) from Export Test Result option in the Run window. 我能够从Android StudioandroidTest instrumentation )运行测试,并且能够从“运行”窗口中的“导出测试结果”选项生成报告(html和xml)。

However I have no clue how to achieve the Html report while running the tests from command line. 但是我不知道如何从命令行运行测试时如何获得HTML报告。

I use the following command to run my tests from Command line. 我使用以下命令从命令行运行测试。

adb shell am instrument -w package.name/android.test.runner.AndroidJUnitRunner

ADB doesn't create these files by itself unfortunately. 不幸的是,亚行不会自行创建这些文件。 Gradle is only able to create these files because google was nice and create a parser for it here Gradle只能创建这些文件,因为google很不错,并在此处为其创建了解析器

https://android.googlesource.com/platform/tools/base/+/android-5.1.1_r6/ddmlib/src/main/java/com/android/ddmlib/testrunner/InstrumentationResultParser.java https://android.googlesource.com/platform/tools/base/+/android-5.1.1_r6/ddmlib/src/main/java/com/android/ddmlib/testrunner/InstrumentationResultParser.java

So when you run a gradle command in android studio it's actually calling that group of code and parsing the standard output from the instrumentation command to create the HTML and XML reports. 因此,当您在android studio中运行gradle命令时,它实际上是在调用该组代码并解析Instrumentation命令的标准输出以创建HTML和XML报告。

You'll need to interpret the standard output some way and create those files yourself. 您需要以某种方式解释标准输出并自己创建这些文件。 This might not be too bad to do given that most of the code for this is already fleshed out from the above link. 鉴于大多数代码已经从上述链接中充实了,所以这样做可能并不算太糟糕。

[update] [更新]

I created this project which should accept the instrumentation output from STDIN and create a junit xml report. 我创建了这个项目,该项目应该接受来自STDIN的检测输出并创建一个junit xml报告。

https://github.com/jamesknowsbest/Instrumentationpretty https://github.com/jamesknowsbest/Instrumentationpretty

can you take a look and let me know if that helps? 您可以看看吗,让我知道是否有帮助?

Hope that helps 希望能有所帮助

-James -詹姆士

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM