【问题标题】:adding metadata to testdroid's junit xml将元数据添加到 testdroid 的 junit xml
【发布时间】:2017-09-29 20:48:53
【问题描述】:

使用 TestDroid 运行 Android Instrumentation 测试时,它会输出 JUnit XML。例如,

<?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&#13;
        at org.junit.Assert.fail(Assert.java:86)&#13;
        ...
      </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>

除了有关测试的元数据之外,它们似乎将 Java 系统属性转储到 xml 中,这非常有用。

我想在 JUnit XML 中添加元数据/属性。关于如何做到这一点的任何想法?

【问题讨论】:

    标签: android testdroid


    【解决方案1】:

    它是基于 ddmlib 功能完成的。 您应该使用com.android.ddmlib.testrunner.RemoteAndroidTestRunner 传递正确的com.android.ddmlib.IDevicecom.android.ddmlib.testrunner.ITestRunListener 的实现(它应该负责收集测试信息和生成junit xml)到run 方法,一旦测试完成,您可以生成xml 并转储到文件,在末尾添加com.android.ddmlib.IDevice#getProperties

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-10-14
      • 1970-01-01
      • 2012-04-14
      • 2013-07-19
      • 2013-09-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多