【问题标题】:producing a correct and complete xml unit testing report (for Hudson)生成正确且完整的 xml 单元测试报告(针对 Hudson)
【发布时间】:2011-04-16 19:37:06
【问题描述】:

我正在扩展 svUnit(R 的单元测试套件,sciViews 的一部分),以便它也产生可供 Hudson 读取的输出。实际上我已经有一些东西可以做到这一点,但它不处理“停用”测试。

要了解我的意思,请查看svTestData.R 文件中的protocol_junit.svTestData 方法。

问题是我没有设法找到 Hudson 接受的架构的任何定义,我确实设法说服 Java 项目失败和错误,因此它的测试套件将添加 <failure/><error/>一些 <testcase/> 元素中的元素,但我没能看到 @Ignore @Test 装饰会发生什么。

许多其他人也问过同样的问题,例如here too,但最后有人问到this page,这是一个很好的起点,但并不完整。例如,它没有提到我通过反复试验发现的<error/> 元素。

我试图阅读 Hudson 阅读的源代码,但我没有找到从哪里开始。

有什么提示吗?

【问题讨论】:

标签: unit-testing r hudson junit4 jenkins


【解决方案1】:

仔细查看了 Hudson 的来源(特别是 CaseResult.java),我发现在 <testcase/> 元素中包含 <skipped/> 元素是我想要的。

仅供将来参考,我正在生成的架构的 RELAX NG 紧凑语法(随意编辑/维护):

junit.rnc:
#----------------------------------------
start = testsuite

property = element property {
   attribute name {text},
   attribute value {text}
}

properties = element properties {
   property*
}

failure = element failure {
   attribute message {text},
   attribute type {text},
   text
}

error = element error {
   attribute message {text},
   attribute type {text},
   text
}

skipped = element skipped {
   text
}

testcase = element testcase {
   attribute classname {text},
   attribute name {text},
   attribute time {text},
   (failure|error)?,
   skipped?
}

testsuite = element testsuite {
   attribute errors {xsd:integer},
   attribute failures {xsd:integer},
   attribute hostname {text},
   attribute name {text},
   attribute tests {xsd:integer},
   attribute time {xsd:double},
   attribute timestamp {xsd:dateTime},
   properties,
   testcase*,
   element system-out {text},
   element system-err {text}
}
#----------------------------------------


and junitreport.rnc
#----------------------------------------
include "junit.rnc" {
   start = testsuites
   testsuite = element testsuite {
      attribute errors {xsd:integer},
      attribute failures {xsd:integer},
      attribute hostname {text},
      attribute name {text},
      attribute tests {xsd:integer},
      attribute time {xsd:double},
      attribute timestamp {xsd:dateTime},
      attribute id {text},
      attribute package {text},
      properties,
      testcase*,
      element system-out {text},
      element system-err {text}
   }
}

testsuites = element testsuites {
   testsuite*
}
#----------------------------------------

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-05-19
    • 2012-08-01
    • 2021-09-27
    • 1970-01-01
    • 1970-01-01
    • 2018-07-26
    • 1970-01-01
    相关资源
    最近更新 更多