2010-12-13 101 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。