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.

Regards,

Celso Yoshioka

Celso,

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
"Clean"
  ==> "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.

https://marketplace.atlassian.com/plugins/com.wwwlicious.xunit.xunit/server/overview

hope this helps.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted 11 hours ago in Featured Groups

Are you managing your users efficiently?

Hi everyone, I am Marek, a Senior Product Manager for Crowd   Server and Data Center   here at Atlassian. I would like to spark a discussion about challenges you have with managing use...

77 views 1 2
View post

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