The Light
The Light

Reputation: 27011

How to configure TeamCity to run only unit tests with certain categories?

I have some unit test fixtures which have been attributed with [Category("Fast")]

How to configure TeamCity so that it runs only the unit tests whose category name is "Fast"?

I'm sure there must be a way.

Upvotes: 8

Views: 7956

Answers (4)

R.Potas
R.Potas

Reputation: 11

I have spent quite some time figuring out how it should be used in VS Tests step: Team City Example

The syntax for VS Tests:

Exclude example: /TestCaseFilter:TestCategory!=Integration

Upvotes: 1

9swampy
9swampy

Reputation: 1471

FWIW to EXCLUDE multiple test categories for the MSTest runner: in Additional command line parameters in "/category:!ServiceDependent" to exclude ServiceDependent tests, or "/category:!ServiceDependent&!EntryPoint" to exclude both ServiceDependent and EntryPoint tests. Of course you need to have decorated the tests accordingly. As to why you'd want to? That's another story...

MSTest category parameter

Upvotes: 3

ccellar
ccellar

Reputation: 10344

When you are using the built-in NUnit build step you could specify the categories which should be tested and which not.

enter image description here

See http://confluence.jetbrains.com/display/TCD8/NUnit

Upvotes: 4

Oleksandr Kobylianskyi
Oleksandr Kobylianskyi

Reputation: 3380

It depends on unit test framework that you are using. Each of them provides an utility to run tests where you can specify some options. It looks smth like this for MS Test: mstest /category:Fast Similar thing is should be present in each unit test framework (NUnit, XUnit).

When you are using Team City you should examine attentively your options for unit tests run and find a place where you can provide this additional option about category (it is usually named like "Command-Line options", "Addition Parameters" or smth similar). I don't remember exactly but I think it should be present in Team City built-in tasks for unt tests run.

Even if built-in tasks for unit tests run are missing this feature you can always switch to general script execution task and run something like this mstest /category:Fast in it.

Upvotes: 2

Related Questions