【问题标题】:What format does the NUnit test results XML need to be to publish back to TFS 2010 build?NUnit 测试结果 XML 需要采用什么格式才能发布回 TFS 2010 版本?
【发布时间】:2018-06-03 13:38:11
【问题描述】:

我有一些 xUnit 测试作为构建的一部分运行,我需要将结果发布回 TFS 2010,以便它们像普通测试一样显示在构建摘要/日志中。

我使用 -nunit 参数执行测试,以便输出是 NUnit xml 而不是 xUnit。我正在尝试使用 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>

【问题讨论】:

    标签: tfs nunit tfsbuild xunit


    【解决方案1】:

    TFS 2010 使用带有“.trx”扩展名的专有结果格式来发布结果,因此我们需要在通过 Web 服务发回之前转置 NUnit 结果。

    你可以使用NUnitTFS for xUnit,试试Ian Battersby提供的工作流模板NUnitAndPublishTemplate.xaml

    详情请参阅 Ian Battersby 的博客:Running and publishing NUnit test results into TFS 2010

    【讨论】:

    • 正如上面构建日志中所说:Transforming NUnit output to .trx file... Adding build information to .trx file... Publishing .trx file... 我已经看到了您提供的所有 3 个链接。还是没有骰子。
    • @J.Doe 是否有可能您没有设置正确的权限来查看测试结果?看到这个链接:blog.ehn.nu/2010/10/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-08
    • 1970-01-01
    • 2016-02-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多