Xunit.net Support?

Our organization uses Xunit.net for our .net unit test framework. Migrating off is not an option. At the same time, we're pretty invested in the Atlassian ecosystem, and we're evaluating Bamboo as a possible build system. In order for us to make the move we need to figure out how to support xunit.net. Is this supported, and if so, can someone point me towards some documentation?

5 answers

I found using FAKE instead of MSBuild made using xUnit quite easy (among other things. Never going back to MSBuild again). Just create your FAKE script by following their calculator example (http://fsharp.github.io/FAKE/gettingstarted.html), add an XUnit task like on their homepage (https://github.com/fsharp/FAKE) and create a bamboo task that calls "build.bat". Then on your FAKE xUnit task, just add a NUnitXmlOutput=true property to have it publish NUnit-style XML test results. (http://fsharp.github.io/FAKE/apidocs/fake-xunithelper-xunitparams.html). Finally add the NUnit parser task to your bamboo build, and it'll publish your results. It's pretty easy and ends up being quite flexible.

Evaluating Bamboo here, and this is how I solve it.

XUnit already includes a XSL Transformation file to convert Xunit.net to NUnit format: NUnitXml.xslt.

Thus, you can add a XslTransformation task in the msbuild project after the xunit task:

<xunit Assembly="%(TestAssemblies2.Identity)" Xml="%(TestAssemblies2.Filename).xml"/>
<XslTransformation XmlInputPaths="%(TestAssemblies2.Filename).xml"  XslInputPath="$(PlatformDir)\Tools\xUnit\NUnitXml.xslt" OutputPaths="NUnit.%(TestAssemblies2.Filename).xml" />

Finally, set the proper file pattern (like NUnit.*.xml) in the NUnit parser.

Hi Paul,

If this framework supports command line you can create a script task in Bamboo to deploy it.

You just need to make sure that the computer that is making the build has all the framework requirements installed.


Celso Yoshioka


Thanks. I hadn't considered that. It does have a command line runner. That should work. Next up will be trying to figure out how to import reports into Jira. I was a little disappointed to find that Bamboo doesn't seem to have much better report format support than Jenkins for .net solutions.

Thanks Dax, that works very well!

We're using the following tasks:

Script - a File script called Product.UnitTests.cmd (this builds the unit test projects and runs the tests using xUnit.net with the XML output set to NUnit format)
NUnit Parser - with the 'NUnit Test Results File/Directory' set to **/testresults/*.xml (this integrates the results into the Bamboo Tests tab)

The Product.UnitTests.cmd looks like:

packages\FAKE.3.5.4\tools\Fake.exe Product.UnitTests.fsx   (where FAKE was installed via NuGet)

The Product.UnitTests.fsx FAKE file looks like:

// We use FAKE (F# Make) to run our xUnit.net tests within Bamboo
// See http://fsharp.github.io/FAKE/gettingstarted.html and http://fsharp.github.io/FAKE/index.html for more info.

// Include Fake library
#r @"packages/FAKE.3.5.4/tools/FakeLib.dll"
open Fake

// Properties
let testDir = "./test/"
let testOutputDir = "./testresults/"

// Clean up
Target "Clean" (fun _ ->
    CleanDirs [testDir; testOutputDir]

// Build unit tests
Target "BuildUnitTests" (fun _ ->
    !! "./*.UnitTests/*.UnitTests.csproj"
        |> MSBuildDebug testDir "Build"
        |> Log "TestBuild-Output: "

// Run unit tests
Target "RunUnitTests" (fun _ ->
    !! (testDir + "*.UnitTests.dll")
        |> xUnit (fun p -> 
            {p with 
                ShadowCopy = false;
                HtmlOutput = true;
                NUnitXmlOutput = true;
                OutputDir = testOutputDir })

// Zip unit test results
Target "ZipUnitTestResults" (fun _ ->    
    !! (testOutputDir + "*.html")
        |> Zip testOutputDir (testOutputDir + "testresults.zip")

// Dependencies
  ==> "BuildUnitTests"
  ==> "RunUnitTests"
  ==> "ZipUnitTestResults"  

// Start Tests
RunTargetOrDefault "ZipUnitTestResults"


Note that the ZipUnitTestResults task is not needed for test integration with Bamboo, but is useful if you wish to add an artifact.

I have created a plugin for parsing xunit results in bamboo and published on the atlassian marketplace.

It should support v1, v2 and dotnet test outputs for xunit.


hope this helps.

Suggest an answer

Log in or Join to answer
Community showcase
Louis De Jaeger
Posted yesterday in Off-topic

Friday fun: your best joke

Hi all Lets make this Friday fun really fun and post one (or more) of your best jokes! The joke can be about an Atlassian product, or just a really fun joke you want to share! I’m not the best j...

86 views 2 2
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot