Search code examples
tfsvisual-studio-test-runner

MS Build TestCategory Filter not working


Environment

  • TFS2013.Update 2 12.0.30324.0
  • C#
  • Visual Studio 2013
  • Visual Studio Test Runner
  • Gated Check-In

Problem

As shown here I decorated my TestMethod like

[TestCategory("Gated"), TestMethod()]

As shown here I filtered, like

TestCategory=Gated

When I build without any filter, the TestRun run successfully with all unit tests. But when I tried to filter over TestCaterory, no TestRun started at all.

I tried without success ...
... to put the filter in quotation:

"TestCategory=Gated"

... to separate the attributes:

[TestMethod]
[TestCategory("Gated")]

... a similar question has been posted here, but I can't revert back to using the old default.xaml.

... I found just one warning in the build log under "Run Visual Studio Test Runner for Test Sources": "Dependent Assembly Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed of C:\Builds2\56\614\bin\External\Microsoft.TeamFoundation.TestManagement.Common.dll not found. Can be ignored if not a NUnit project."
-> I added the reference to Newtonsoft.Json in every single NUnit-Project in all the solutions, that were build during the gated check-in - also without success.


Solution

  • The problem was not the TestCategory, but another pretty simple one:
    The unittest-project in which the “broken” testmethod resides was not part of ”projects to Build” of the Build Definition.