![](/img/trans.png)
[英]Add failing test to JUnit XML using junit-xml python module
[英]Python for predefined Junit XML
我必须开发一个Python脚本,以以下格式生成Junit XML
<?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>
我做了一个基本的python代码,但无法标记如上所示
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
请针对以上内容提出您的建议
可以使用junit_xml中的Decode导入TestSuite,TestCase,Decode来完成
从上面我们可以将测试用例标记为失败/跳过等
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.