您必须使用XUnit2Aliases.XUnit2(IEnumerable < FilePath >,XUnit2Settings) + XmlPeekAliases来读取 XUnit 输出。
var testAssemblies = GetFiles("./src/**/bin/Release/*.Tests.dll");
XUnit2(testAssemblies,
new XUnit2Settings {
Parallelism = ParallelismOption.All,
HtmlReport = false,
NoAppDomain = true,
XmlReport = true,
OutputDirectory = "./build"
});
xml 格式为:(XUnit 文档,示例源,Reflex 中的更多信息)
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="nosetests" tests="1" errors="1" failures="0" skip="0">
<testcase classname="path_to_test_suite.TestSomething"
name="test_it" time="0">
<error type="exceptions.TypeError" message="oops, wrong type">
Traceback (most recent call last):
...
TypeError: oops, wrong type
</error>
</testcase>
</testsuite>
那么下面的代码片段应该会给你带来信息:
var file = File("./build/report-err.xml");
var failuresCount = XmlPeek(file, "/testsuite/@failures");
var testsCount = XmlPeek(file, "/testsuite/@tests");
var errorsCount = XmlPeek(file, "/testsuite/@errors");
var skipCount = XmlPeek(file, "/testsuite/@skip");