2010-12-13 105 views
6

我需要一个报告的XUnit测试的NUnit输出。随着NUnit的,我可以这样做:如何使用XUnit控制台输出NUnit格式的xml?

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

我已经试过:

xunit.console MyDll.dll /nunit TestResults.xml 

,但我得到:

unknown output transform: nunit 

的xUnit控制台上的任何好的文档?我找不到任何信息。

回答

19

在控制台中键入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文件,并且在xunit.console.exe.config文件中声明条目nunit

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。