mocha-junit-reporter
Last updated
Was this helpful?
Last updated
Was this helpful?
生成 JUnit-style 的XML测试结果。
或者作为一个全局模块
运行mocha与 mocha-junit-reporter:
这将在./test-results.xml
输出结果文件。可以通过设置环境变量``MOCHA_FILE```或在
mochaFile`中指定reporterOptions,可选地设置XML文件结果的替代位置:
或
或
还可以在testsuite下向报表添加属性。如果您希望您的CI环境为分析目的添加报表的额外构建道具,这将非常有用。
这样做通过env变量传递它们:
或
结果XML文件名可以包含[hash]
,例如/path_to_your/test-results.[hash].xml
。[hash]
由测试结果XML的MD5哈希替换。这支持在多个文件中并行执行多个mocha-junit-reporter
的编写测试结果。
为了显示完整的组别标题(包括parents),只需指定testsuitesTitle
选项.
如果希望切换生成的testCase XML
条目的classname和name,可以使用testCaseSwitchClassnameAndName
选项。
下面是使用testCaseSwitchClassnameAndName
选项的XML输出示例:
value
XML output
true
<testcase name="should behave like so" classname="Super Suite should behave like so">
false
(default)
<testcase name="Super Suite should behave like so" classname="should behave like so">
还可以通过设置reporterOptions.testsuitesTitle
来配置testsuites.name
属性,并通过设置reporterOptions.testsuitesTitle
来配置根suite的name属性。
Parameter
Effect
mochaFile
configures the file to write reports to
includePending
if set to a truthy value pending tests will be included in the report
properties
a hash of additional properties to add to each test suite
toConsole
if set to a truthy value the produced XML will be logged to the console
useFullSuiteTitle
if set to a truthy value nested suites' titles will show the suite lineage
suiteTitleSeparedBy
the character to use to separate nested suite titles. (defaults to ' ')
testCaseSwitchClassnameAndName
set to a truthy value to switch name and classname values
rootSuiteTitle
the name for the root suite. (defaults to 'Root Suite')
testsuitesTitle
the name for thetestsuites
tag (defaults to 'Mocha Tests')