19 November 2018

Filtering XUnit Test by Trait in TeamCity

We were configuring our TeamCity instance to not run xunit tests with the category=integration. We ran into some interesting behavior of TeamCity, where the ".NET Process Runner" auto-quotes each line!

Our original configuration attempt was setting the .NET Process Runner with the following configuration:

  • Runner type:
    .NET Process Runner
  • Path:
    \path\to\xunit.console.exe
  • Command line parameters:
    Corp.Tests.dll
    Corp.Web.Tests.dll
    -notrait category=integration
    

However, we received the following error from xunit:

error: unknown option: -notrait category=integration

It turns out that if you use newline-separated command line parameters, teamcity will quote every line. So to pass a value to a parameter, you need to also use a newline to separate them:

Corp.Tests.dll
Corp.Web.Tests.dll
-notrait
category=integration