Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I output NUnit formatted xml with XUnit console?

Tags:

xunit

I need NUnit output from XUnit tests for a report. With NUnit I can do:

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

I've tried:

xunit.console MyDll.dll /nunit TestResults.xml

but I get:

unknown output transform: nunit

Any good docs on xunit console? I can't find any info.

like image 704
JontyMC Avatar asked Dec 13 '10 17:12

JontyMC


1 Answers

Type xunit.console.exe /? in a console and look at the end of the option list.

> 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

The last two options are extracted from the config file and consist of a xslt file applied to the output of xunit. If /nunit is not present, make sure that you have the NUnitXml.xslt file in the xunit directory and the entry nunit is declared in the xunit.console.exe.config file.

My xunit.console.exe.config file :

<?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>

If you're not able to find theses files, you might need to reinstall xunit.

like image 196
Nekresh Avatar answered Oct 23 '22 11:10

Nekresh