xunit - 如何使用XUnit控制台输出NUnit格式的xml?

标签 xunit

我需要XUnit测试的NUnit输出来生成报告。使用NUnit,我可以执行以下操作:

nunit-console.exe /xml=c:\TestResultN.xml MyDll.dll

我试过了:
xunit.console MyDll.dll /nunit TestResults.xml

但我得到:
unknown output transform: nunit

在xunit控制台上有任何好的文档吗?我找不到任何信息。

最佳答案

在控制台中键入xunit.console.exe /?,然后查看选项列表的末尾。

> xunit.console.exe /?
xUnit.net console test runner (64-bit .NET 2.0.50727.4952)
Copyright (C) 2007-10 Microsoft Corporation.

usage: xunit.console <xunitProjectFile> [options]
usage: xunit.console <assemblyFile> [configFile] [options]

Valid options:
  /silent                : do not output running test count
  /teamcity              : forces TeamCity mode (normally auto-detected)
  /wait                  : wait for input after completion

Valid options for assemblies only:
  /noshadow              : do not shadow copy assemblies
  /xml <filename>        : output results to Xunit-style XML file
  /html <filename>       : output results to HTML file
  /nunit <filename>      : output results to NUnit-style XML file

最后两个选项是从配置文件中提取的,并且包含一个应用于xunit输出的xslt文件。如果不存在/nunit,请确保在xunit目录中具有NUnitXml.xslt文件,并且在nunit文件中声明了xunit.console.exe.config条目。

我的xunit.console.exe.config文件:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <configSections>
    <section name="xunit" type="Xunit.ConsoleClient.XunitConsoleConfigurationSection, xunit.console"/>
  </configSections>

  <xunit>
    <transforms>
      <add
        commandline="html"
        xslfile="HTML.xslt"
        description="output results to HTML file"/>
      <add
        commandline="nunit"
        xslfile="NUnitXml.xslt"
        description="output results to NUnit-style XML file"/>
    </transforms>
  </xunit>

</configuration>

如果找不到这些文件,则可能需要重新安装xunit。

关于xunit - 如何使用XUnit控制台输出NUnit格式的xml?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4431536/

相关文章:

java - 解决 JUnit 中的重复测试习语

F#XUnit测试不打印输出

msbuild - vstest.console.exe 未生成 trx 文件,TestResults 为空

azure-devops - .NET Core 2.0 xUnit 测试未在 VSTS 中发现

asp.net-core - 在 ASP.NET Core 中解决集成测试中的依赖项

c# - 您如何测试是否已创建对象的新实例?

xunit - 在 xUnit 2.x 中的我的测试类上使用多个 collectionfixture

c# - Moq - 将参数从 setup() 传递到 Returns()

python - 在 pytest 中使用 conftest 设置/拆卸

unit-testing - 在未安装 SDK 的情况下运行 xUnit 测试