Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Xunit.net Support?

Paul Christensen September 26, 2013

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

1 vote
Miguel Bautista October 3, 2014

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.

1 vote
Dax Fohl February 10, 2014

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.

0 votes
Scott M February 2, 2017

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.

0 votes
Ian Lovell September 23, 2014

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.

0 votes
CelsoA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 26, 2013

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

Paul Christensen September 26, 2013

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.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events