我有一些xUnit测试作为构建的一部分运行,我需要将结果发回TFS 2010,这样它们就会像普通测试那样出现在构建摘要/日志中。
我使用-nunit参数执行测试,以便输出是NUnit xml,而不是xUnit xml。我正在尝试使用NUnit4TeamBuild将结果xml发布回TFS,它看起来很有效,但最终没有测试结果。
这是该步骤的详细日志:
Publish xUnit Results
NUnitTfs.exe -n results.xml -t Project -b "Build_20171221.8" -v 2010
Loading NUnit Output from results.xml...
Transforming NUnit output to .trx file...
Adding build information to .trx file...
Publishing .trx file...
Checking test run does not exist...
Reading users identity...
Creating test run...
Creating test results...
Updating test run with details...
Uploading test run details...
Uploading assemblies...
Updating test results with details...
Uploading test result details...生成以0错误和0警告结束,但在构建摘要中还会显示"No Test Results“,而且在任何地方都没有测试结果。
我不知道为什么测试不发表。
下面是它试图发布的XML示例(请注意,我已经更改了文件路径并缩短了堆栈跟踪):
<?xml version="1.0" encoding="utf-8"?>
<test-results name="Test results" errors="0" inconclusive="0" ignored="0" invalid="0" not-run="0" date="2017-12-21" time="08:39:57" total="1" failures="1" skipped="0">
<environment os-version="unknown" platform="unknown" cwd="unknown" machine-name="unknown" user="unknown" user-domain="unknown" nunit-version="xUnit.net 2.3.1.3858" clr-version="64-bit .NET 4.0.30319.34209 [collection-per-class, non-parallel]" />
<culture-info current-culture="unknown" current-uiculture="unknown" />
<test-suite type="Assemblies" name="C:\Tests.DLL" executed="True" success="False" result="Failure" time="57.41">
<results>
<test-suite type="Assembly" executed="True" name="C:\Tests.DLL" result="Failure" success="False" time="57.410">
<results>
<test-suite type="TestCollection" executed="True" name="Tests" result="Failure" success="False" time="48.992">
<results>
<test-case name="Google_Search_Test" executed="True" result="Failure" success="False" time="48.9917024">
<failure>
<message>System.Exception : Test Failed. Exception has been thrown by the target of an invocation.</message>
<stack-trace>at Tests.Fixtures.Fixture.FormatException(Exception e) in... etc. </stack-trace>
</failure>
</test-case>
</results>
</test-suite>
</results>
</test-suite>
</results>
</test-suite>
</test-results>发布于 2017-12-21 08:40:59
TFS 2010使用带有“.trx”扩展的专有结果格式来发布结果,因此在通过web服务返回之前,我们需要转换NUnit结果。
您可以使用NUnitTFS for xUnit,只需尝试由Ian 提供的工作流模板NUnitAndPublishTemplate.xaml。
详情请参阅Ian 的博客:运行并将NUnit测试结果发布到TFS 2010中。
https://stackoverflow.com/questions/47915428
复制相似问题