Skip to content

This is a short java program implemented to accept the standard instrumentation output from Android tests and create HTML and junit XML reports

Notifications You must be signed in to change notification settings

lorenz-jumio/Instrumentationpretty

 
 

Repository files navigation

InstrumentationPretty

This is a short java program implemented to accept the standard instrumentation output from Android test and create HTML and junit XML reports.

WARNING: This software is used as-is without any warranty. Please use your own judgement when using this for your project.

What issue does this solve?

In some cases, you may only need to run an adb command to execute the tests. In this case, the only output you would receive is the standard instrumentation output which isn't easily human readable. It also creates a junit XML report which you can us in Jenkins or similar software.

Solution

The android tools for gradle has actually already implemented a parser here. However, it's built for listening to tests and not for reading from STDIN. This code repository is a slight modification of that code base and is intended to be used with the standard output from an instrumentation command which is written to a file.

example usage

Building

./gradlew clean shadowJar

Running

Using with a ADB instrument command

adb shell am instrument -w <test_package_name>/<runner_class> | java -classpath /path/to/Instrumentationpretty-all.jar InstrumentationPretty

Using with an existing file

cat /path/to/instrument/log/file | java -classpath /path/to/Instrumentationpretty-all.jar InstrumentationPretty

Specify output directory

cat /path/to/instrument/log/file | java -classpath /path/to/Instrumentationpretty-all.jar InstrumentationPretty -o <yourDirectoryHere>

Note: if the directory doesn't exist it will be created. By default the output directory is the current working directory/reports as shown by this line in InstrumentationPretty.java

reportDir = new File(System.getProperty("user.dir") + "/reports");

example html output

example html output

example junit output

<?xml version='1.0' encoding='UTF-8' ?>
<testsuite name="Instrumentation results" tests="1" failures="0" errors="0" time="2.798" timestamp="2019-01-13T01:08:25" hostname="localhost">
  <properties />
  <testcase name="testAlert" classname="com.amazonaws.devicefarm.android.referenceapp.Categories.AlertPageTest" time="0.0" />
</testsuite>

About

This is a short java program implemented to accept the standard instrumentation output from Android tests and create HTML and junit XML reports

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%