如何使用bazel向junit xml报告添加自定义属性?

问题描述

我使用 bazel 来运行测试。 我想向 junit xml 报告的 <testcase> 节点添加一个自定义属性

举个例子,认情况下 bazel生成这个:

<?xml version='1.0' encoding='UTF-8'?>
<testsuites>
  <testsuite name='com.test.MySpec' timestamp='2021-05-24T11:48:54.815Z' hostname='localhost' tests='1' failures='0' errors='0' time='60.206' package='' id='0'>
    <properties />
        <testcase name='test1' classname='com.test.MySpec' time='60.206' />
    <system-out />
    <system-err />
    </testsuite>
</testsuites>

据我所知,bazel 负责生成 junit xml 报告,并在内部使用 AntXmlResultWriter 类来创建 xml 报告。

所以我的问题是是否可以添加我的属性,如果可以,那么最简单和最直接的方法是什么,以便我得到:

<?xml version='1.0' encoding='UTF-8'?>
<testsuites>
  <testsuite name='com.test.MySpec' timestamp='2021-05-24T11:48:54.815Z' hostname='localhost' tests='1' failures='0' errors='0' time='200.962' package='' id='0'>
    <properties />
        <testcase name='test1' classname='com.test.MySpec' time='60.206' myattr="Custom attribute"/>
    <system-out />
    <system-err />
    </testsuite>
</testsuites>

注意myattr="自定义属性"

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)