junitparser
junitparser copied to clipboard
TestCase might not have result
Hi,
According to junit schema a test case have a sequence with skipped, error, failure, system-out and system-err with minimum occurrenses of 0.
When updating statistics this is causing the suite to have all skipped, error, failure values as 0 if the test cases does not have this value.
e.g:
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="com.example.suiteTest" time="0.147" tests="1" errors="1" skipped="0" failures="0">
<testcase name="createTest" classname="com.example.suiteTest" time="0.147"/>
</testsuite>
xml1 = JUnitXml.fromfile('example.xml')
print(xml1)
xml1.update_statistics()
print(xml1)
result:
<Element 'testsuite' errors="0" failures="1" name="com.example.suiteTest" skipped="0" tests="1" time="0.022">
<Element 'testsuite' errors="0" failures="0" name="com.example.suiteTest" skipped="0" tests="1" time="0.022">
the issue might be solved by adding an if condition in the update_statistics:
if self.errors > 0 and errors == 0:
errors = self.errors
if self.failures > 0 and failures == 0:
failures = self.failures
if self.skipped > 0 and skipped == 0:
skipped = self.skipped