简体   繁体   中英

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

I am a beginner and using UIautomator for Android instrumentation. 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.

However I have no clue how to achieve the Html report while running the tests from command line.

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

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.

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.

https://github.com/jamesknowsbest/Instrumentationpretty

can you take a look and let me know if that helps?

Hope that helps

-James

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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