Skip to content
This Extensible Stylesheet Language Transformations can transform a xUnit.net v2 XML test results file into a JUnit test results file.
C# XSLT Shell
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
setup
src
tests/XsltTests add netcoreapp3.0 support Apr 26, 2019
.editorconfig Insert final new line Jan 18, 2018
.gitattributes Mark ps files as vendored Jul 29, 2018
.gitignore add netcoreapp3.0 support Apr 26, 2019
GitVersion.yml
LICENSE
README.md Stop publishing features branch to MyGet Jun 30, 2019
appveyor.yml Update NuGet key Jun 30, 2019
bootstrap.ps1 Upgrade Cake Tool Jun 30, 2019
bootstrap.sh
build.cake Migrate to Cake global tool Jan 12, 2019
xUnitToJUnit.sln

README.md

xUnit.net v2 XML Format to JUnit Format

Package Release
dotnet-xunit-to-junit NuGet
CI Status Platform(s) Framework(s) Test Framework(s)
AppVeyor Build Status Windows netcoreapp2.1, netcoreapp3.0 netcoreapp3.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.

Consume the transform

Consume JUnit.xslt through the dotnet-xunit-to-junit NuGet package

dotnet-xunit-to-junit is a .NET Core 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"

Consume JUnit.xslt directly from C#

Note: For .NET Core, this requires nestandard2.0 and above.

// 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);

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);
}

Running locally

Install the .NET Core SDK 3.0.100-preview6-012264.

Once you're done, run this command to initialise Cake:

.\bootstrap.ps1

You can then run the build script:

dotnet cake build.cake

If you want to pack the .NET Core Global Tool you can run: dotnet cake build.cake --pack

You can’t perform that action at this time.