Stef Heyenrath
Stef Heyenrath

Reputation: 9820

How to exclude unit-tests with TestCaseFilter in TFS Build which do contain a namespace

I want to exclude all tests which include Abc in the namespace.

What is the correct pattern to use ?

!(FullyQualifiedName~.Abc.) 

is not valid ?

I used this web-page as reference : http://blogs.msdn.com/b/visualstudioalm/archive/2012/09/26/running-selective-unit-tests-in-vs-2012-using-testcasefilter.aspx

Upvotes: 4

Views: 1388

Answers (1)

Cece Dong - MSFT
Cece Dong - MSFT

Reputation: 31003

There is no such pattern !(FullyQualifiedName~.Abc.) in build definition.

Use Test Case Filter in XAML build definition to select tests to run based on filter criteria. You can use the format Operator to construct your filter where Operator is one of =,!= or ~. You can also use the logical operator |, & to construct your filter and parenthesis() for grouping.

To achieve what you want, you can:

  • Give each of your Unit test except containing "Abc" a priority (maybe 1), and give unit tests containing "Abc" a priority (maybe2). In the test case filter, set “Proirity=1*”, then you can exclude the unit tests contain "Abc".
  • In another way, you can filter out unit tests not contain "Abc" by Test assembly file name. Identify unit tests not contain "Abc" based on a naming pattern Def.Tests.dll, then in the Test assembly file specification blank, input “**\ *Def.Tests.dll”.

Similar case: https://social.msdn.microsoft.com/Forums/vstudio/en-US/d415dbdd-74a0-484b-a5ae-e5af3e985e94/how-to-explicitly-exclude-assemblies-in-test-runner-during-tfs-build?forum=tfsgeneral

Upvotes: 1

Related Questions