If I run a set of unit tests in Android Studio (would apply in IntelliJ IDEA as well) then I am able to export the test results using this dialog:
If I choose "Export format/HTML" I get a file that renders like this:
which is all very well. However, I have a requirement where I must present the test report in a Word file with a template. If I copy/paste the default HTML in the browser it seems the HTML is too complex for Word to handle correctly and it doesn't look good.
I need some kind of plain text representation of the test report that I can copy into Word/Excel and include as part of a report.
As can be seen on the dialog box above, one of the options is to apply a XSL template to generate results. I would like to write a XSL template to render the JUnit unit test report as something simple that I can copy/paste easily. Note there is no XSL template provided by default with Android Studio or IntelliJ IDEA.
If I export the XML for a minified JUnit test report it looks like this:
<?xml version="1.0" encoding="UTF-8"?><testrun duration="1" footerText="Generated by Android Studio on 4/05/17 12:43 PM" name="myapplication in app">
<count name="total" value="3"/>
<count name="passed" value="3"/>
<config nameIsGenerated="true" configId="AndroidJUnit" name="myapplication in app">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea"/>
<module name="app"/>
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false"/>
<option name="ALTERNATIVE_JRE_PATH"/>
<option name="PACKAGE_NAME"/>
<option name="MAIN_CLASS_NAME"/>
<option name="METHOD_NAME"/>
<option name="TEST_OBJECT" value="directory"/>
<option name="VM_PARAMETERS"/>
<option name="PARAMETERS"/>
<option name="WORKING_DIRECTORY"/>
<option name="ENV_VARIABLES"/>
<option name="PASS_PARENT_ENVS" value="true"/>
<option name="TEST_SEARCH_SCOPE">
<value defaultName="singleModule"/>
</option>
<envs/>
<dir value="/Users/example/AndroidStudioProjects/MyApplication5/app/src/test/java/com/example/myapplication"/>
<patterns/>
</config>
<root name="<default package>" location="java:suite://<default package>"/>
<suite duration="1" locationUrl="java:suite://com.example.myapplication.ArithmeticTest" name="ArithmeticTest" status="passed">
<test duration="1" locationUrl="java:test://com.example.myapplication.ArithmeticTest.multiplication_isCorrect" name="ArithmeticTest.multiplication_isCorrect" status="passed"/>
<test duration="0" locationUrl="java:test://com.example.myapplication.ArithmeticTest.addition_isCorrect" name="ArithmeticTest.addition_isCorrect" status="passed"/>
</suite>
<suite duration="0" locationUrl="java:suite://com.example.myapplication.StringTest" name="StringTest" status="passed">
<test duration="0" locationUrl="java:test://com.example.myapplication.StringTest.concatenation_isCorrect" name="StringTest.concatenation_isCorrect" status="passed"/>
</suite>
</testrun>
Question: What is an XSL template I can apply to get a transformation of the XML into a very plain HTML that I can copy/paste into a Word file for the company?
Note: presented as a self-answered question but other answers are welcome and will be accepted if good quality