TeamCity is a great Continuous Integration tool, with support for pretty much any testing framework, including xUnit, but the standard process for running xUnit tests with TeamCity could be easier.
The process requires MSBuild and nUnit to be available on all applicable build agents. After reading A Step by Step Guide: Create a custom TeamCity MetaRunner to notify NewRelic that a new deployment has occurred by Howard van Rooijen, I decided to have a go at creating a meta runner plugin for xUnit tests. The result is the snappily named "TeamCity xUnit meta runner".
The plugin is easy to install, just download the latest release and place the zip file in the [Team City Data Directory]\plugins directory on the Team City Server, by default this is C:\ProgramData\JetBrains\TeamCity\plugins, then restart the TeamCity server.
After doing this you will see a new build step type "xUnit" where you can then select the xUnit tests to run. The plugin will ensure the xUnit files are correctly copied to all applicable build agents and report test results into TeamCity.
Feel free to check out the code on Github, and submit Pull Requests or Issues.
Sounds cool! Can you please add white list and black list? Like NUnit or MSTest runners. So I could specify a path containing wildcards.
Also AppVeyor build seems broken: ci.appveyor.com/.../team-city-xunit-meta-runner
If xunit runner doesn't support multiple assemblies directly, you could support a list of them (execute runner for each entry in the list) or a project file.
The AppVeyor build is green again :)
xUnit doesn't currently support wildcards for specifying assemblies, you can do this with MSBuild (http://xunit.codeplex.com/wikipage?title=HowToUseMSBuild), but I wanted to keep this as simple as possible and avoid the dependency on MSBuild.
I'll add an issue to the GitHub project and see if I (or anybody else) can think of anyway to do this without adding extra dependencies.
In the meantime there are two options:
1. The MSBuild route detailed on the xUnit site
2. Adding multiple build steps in TeamCity, one for each assembly
Hmmm I was considering migrating our MSTests to xUnit but I think I might have to go for NUnit. I don't want to have a dependency on msbuild just to run multiple test assemblies.
This is how nunit does it, it seems.
Unfortunately the xUnit console application currently does not allow you to specify multiple assemblies to run the tests from in the same way NUnit does.
The plugin could be changed to use MSBuild in that case, but as you mentioned adding a dependency on MSBuild isn't great, and goes against the reason I created this.
It may be possible to make the plugin call the console application multiple times (once for each assembly) but I'm not sure how well that would work.
Unfortunately, I think if you want to run tests from multiple assemblies I think you need to use one of the approaches in my previous comment or a different testing framework.
Hi, I'm getting the following error when trying to use Your plug-in
xUnit.net console test runner (64-bit .NET 4.0.30319.34014)
[18:46:10][Step 1/1] Copyright (C) 2014 Outercurve Foundation.
[18:46:10][Step 1/1] System.ArgumentException: Unknown test framework: Could not find xunit.dll or xunit.execution.dll.
[18:46:10][Step 1/1] Parameter name: Services\bin\Debug\MatterManagement.NewServices.Tests.dll
Could You help me solve this ?