🚨 If you're using this tool to process test results file(s) after having run dotnet test, I recommend using the JUnit Test Logger instead. The output is better (at least in CircleCI). If you can't install an additional NuGet package in your test project(s), can't modify your build or are processing test results file(s) that have previously been generated, please read on.
| Package | Release |
|---|---|
dotnet-xunit-to-junit |
| CI | Status | Platform(s) | Framework(s) | Test Framework(s) |
|---|---|---|---|---|
| GitHub | Ubuntu |
net8.0 |
net8.0 |
CircleCI can only parse test results in the JUnit format. This Extensible Stylesheet Language Transformations can transform a xUnit.net v2 XML test results file into a JUnit test results file.
Note: this only handles the easiest use case for the moment, as soon as I encounter issues in real life usage I'll add extra testing scenarios.
dotnet-xunit-to-junit is a .NET global tool:
dotnet tool install -g dotnet-xunit-to-junit
dotnet xunit-to-junit "path-to-xunit-test-results.xml" "desired-path-to-junit-test-results.xml"// Required using statement
using System.Xml.Xsl;
// Change the value of these three variables
const string inputFilePath = "C:/tmp/xunit.xml";
const string outputFilePath = "C:/tmp/junit.xml";
const string xsltFilePath = "C:/tmp/JUnit.xslt";
var xlsTransform = new XslCompiledTransform();
xlsTransform.Load(xsltFilePath);
var writerSettings = xlsTransform.OutputSettings.Clone();
// Save without BOM, CircleCI can't read test results files starting with a BOM
writerSettings.Encoding = new UTF8Encoding(false);
using (var stream = new FileStream(outputFilePath, FileMode.Create, FileAccess.Write))
using (var results = XmlWriter.Create(stream, writerSettings))
{
xlsTransform.Transform(inputFilePath, results);
}Run this command to build on Windows:
.\build.ps1Run this command to build on Linux / macOS:
./build.shIf you want to pack the .NET Global Tool, you can run .\build.ps1 --package.