I have to develop a python script that produces a Junit XML in following format
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuite name="Scenario3" time="0.015">
<testcase name="testcase09"/>
<testcase name="testcase10">
<skipped />
</testcase>
<testcase name="testcase11">
<failure type="AssertionFailure">
<![CDATA[ Failed 1 times. ]]>
</failure>
</testcase>
</testsuite>
</testsuites>
I did a basic python code but not able to mark as shown above
from junit_xml import TestSuite, TestCase
test_cases = []
for result in results:
tc_name, tc_result = result
if tc_result == "PASS":
test_cases.append(TestCase(tc_name))
ts = TestSuite("S", test_cases)
print(TestSuite.to_xml_string([ts]))enter code here
Please do give your suggestion for the above
This can be done using Decode from junit_xml import TestSuite, TestCase, Decode
From the above we can mark test cases as fail/skipped etc
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.