自动将样式表声明添加到 ci_reporter xml 文件

发布于 2024-09-27 10:15:47 字数 920 浏览 1 评论 0原文

我不是程序员,所以如果我的问题对你们中的许多人来说相当容易解决(但我仍然可能觉得它令人困惑),请原谅。

我遇到的问题是 ci_reporter,它是与 Watir 和 Test/Unit 一起使用的 gem。

它将 Watir 测试的测试结果输出到 xml 文件。到目前为止很棒。不幸的是,我找不到一种方法让 ci_reporter 在 xml 声明之后添加 xsl 样式表声明。

<?xml version="1.0" encoding="UTF-8"?>
<testsuite time="6.796" assertions="1" name="TC_LoginTests" failures="0" tests="1" skipped="0" errors="0">
  <testcase time="6.796" assertions="1" name="test_loginValid">
  </testcase>

我想要它做的是:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="stylesheet.xsl"?>
<testsuite time="6.796" assertions="1" name="TC_LoginTests" failures="0" tests="1" skipped="0" errors="0">
 <testcase time="6.796" assertions="1" name="test_loginValid">
 </testcase>

我想也许会有一个参数可以在某处设置,但如果有的话我还没有找到。每次都手动添加样式表声明会非常繁琐。

这个问题有简单的解决办法吗?

I am not a programmer, so please be forgiving if my problem is fairly easy to solve for many of you (yet I still might find it confusing).

The problem I am having is with ci_reporter, a gem for use with Watir and Test/Unit.

It is outputting the test results from a Watir test to an xml file. Great so far. Unfortunately I cannot find a way to have ci_reporter add a xsl stylesheet declaration just after the xml declaration.

<?xml version="1.0" encoding="UTF-8"?>
<testsuite time="6.796" assertions="1" name="TC_LoginTests" failures="0" tests="1" skipped="0" errors="0">
  <testcase time="6.796" assertions="1" name="test_loginValid">
  </testcase>

What I want it to do is:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="stylesheet.xsl"?>
<testsuite time="6.796" assertions="1" name="TC_LoginTests" failures="0" tests="1" skipped="0" errors="0">
 <testcase time="6.796" assertions="1" name="test_loginValid">
 </testcase>

I thought perhaps there would be a parameter to set somewhere, but I have not found it if there is one. It will be quite tedious to add the stylesheet declaration manually each time.

Is there a simple solution to this problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

蓦然回首 2024-10-04 10:15:47

我认为如果不破解 ci_reporter 的源代码,您将无法实现您想要的目标。 ci_reporter 旨在输出 JUnit 格式的 XML 文件,并且不提供任何更改此设置的方法。

我将保留 XML 输出原样,然后使用其他内容来应用 xsl 转换作为第二步。

I don't think you will be able to achieve what you want without hacking the source of ci_reporter. ci_reporter is designed to output JUnit format XML files, and doesn't offer any way to change this.

I would leave the XML output as it is, and then use something else to apply your xsl transformation as a secondary step.

流绪微梦 2024-10-04 10:15:47

事实证明,通过更改 ci_reporter gem 中的 test_suite.rb 文件来做到这一点非常简单。不确定这有多合适,但它可以做到我需要它做的事情。

在 to_xml 方法中,我们更改了以下行:

builder.instruct!

改为读取

builder.instruct!
builder.instruct! 'xml-stylesheet', {:href=>'output.xsl', :type=>'text/xsl'}

Turns out it's quite simple to do by altering the test_suite.rb file in the ci_reporter gem. Not sure how proper that is, but it gets it to do what I need it to.

In the to_xml method, we altered the following line:

builder.instruct!

to instead read

builder.instruct!
builder.instruct! 'xml-stylesheet', {:href=>'output.xsl', :type=>'text/xsl'}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文