When running Android Instrumentation tests with TestDroid, it outputs JUnit XML. e.g.,
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<testsuites>
  <testsuite errors="0" failures="1" hostname="Acer Iconia Tab A1-810 - YSF6Y9HE6SQCOJPV" name="ExampleInstrumentedTest" package="com.myco.androidtest" tests="2" time="0.0000" timestamp="Fri Sep 29 21:29:49 CEST 2017">
    <testcase classname="com.myco.androidtest.ExampleInstrumentedTest" name="someTest" time="0.0000"/>
    <testcase classname="com.myco.androidtest.ExampleInstrumentedTest" name="someOtherTest" time="0.0000">
      <failure message="" type="">java.lang.AssertionError
        at org.junit.Assert.fail(Assert.java:86)
        ...
      </failure>
    </testcase>
  </testsuite>
  <properties>
    ...
    <property name="ro.product.manufacturer" value="Acer"/>
    <property name="ro.serialno" value="32206769320"/>
    <property name="ro.product.name" value="a1-810_ww_gen1"/>
    <property name="ro.build.version.release" value="4.2.2"/>
    <property name="ro.build.version.sdk" value="17"/>
    <property name="ro.build.fingerprint" value="acer/a1-810_ww_gen1/mango:4.2.2/JDQ39/1381313631:user/release-keys"/>
    <property name="ro.product.cpu.abi" value="armeabi-v7a"/>
    <property name="ro.product.model" value="A1-810"/>
  </properties>
</testsuites>
In addition to metadata about the tests, it seems like they're dumping Java system properties into the xml, which is pretty useful.
I'd like to add to the metadata/properties in the JUnit XML. Any ideas on how that can be done?
 
                        
It's done based on ddmlib functionalities. You should use
com.android.ddmlib.testrunner.RemoteAndroidTestRunnerpassing propercom.android.ddmlib.IDeviceand your implementation ofcom.android.ddmlib.testrunner.ITestRunListener(which should be responsible for collecting test info and generating junit xml) torunmethod, once test is finished you can generate xml and dump to file, addingcom.android.ddmlib.IDevice#getPropertiesat the end.