0
這裏是我的Junit測試結果.xml 我能夠獲得測試套件和測試用例節點。現在我需要檢查測試用例是否失敗。 我正在使用一種方法檢查testcase節點是否有任何子節點,然後檢查該子節點是否爲故障節點。但是,當我嘗試獲取子節點及其類型時,它僅返回TEXT_NODE並顯示失敗消息文本。如何檢查子節點是否失敗?Junit 4測試結果解析無法找到<failure>標記
<?xml version='1.0' encoding='UTF-8' ?>
<testsuite name="com.Test" tests="47" failures="1" errors="0" skipped="0" time="0.425" timestamp="2017-05-25T10:04:14" hostname="localhost">
<properties>
<property name="device" value="Nexus_6_API_22(AVD) - 5.1.1" />
<property name="flavor" value="DEV" />
<property name="project" value="test" />
</properties>
<testcase name="test_1" classname="com.Test" time="0.053" />
<testcase name="test_2" classname="com.Test" time="0.081" />
<testcase name="test_3" classname="com.Test" time="0.0" />
<testcase name="test_4" classname="com.Test" time="0.001">
<failure>junit.framework.ComparisonFailure: expected:<512[]> but was:<512[fed_]>
at junit.framework.Assert.assertEquals(Assert.java:85)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1853)
</failure>
</testcase>
</testsuite>