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

I have some unit test fixtures that have been attributed using [Category ("Fast")]

How to configure TeamCity to run only unit tests whose category name is "Fast"?

I am sure there must be a way.

+6
source share
3 answers

FWIW to exclude several test categories for the MSTest runner: in the additional command line parameters in "/category:!ServiceDependent" to exclude ServiceDependent tests or "/category:!ServiceDependent&!EntryPoint" to exclude ServiceDependent and EntryPoint . Of course, you should format your tests accordingly. What would you like? This other story ...

MSTest category parameter

+3
source

It depends on the unit test structure you are using. Each of them provides a utility for running tests, where you can specify some parameters. It looks like this for MS Test: mstest /category:Fast A similar thing should be present in every unit test structure (NUnit, XUnit).

When you use Team City, you should carefully study your options for running unit tests and find a place where you can provide this additional parameter about the category (it is usually called “Command Line Parameters”, “Add Parameters” or something similar). I don’t remember exactly, but I think that he should be present in Team City’s built-in tasks to run tests.

Even if the built-in tasks for running unit tests do not have this function, you can always switch to the general script execution task and run something like this mstest /category:Fast .

+2
source

When you use the built-in NUnit build step, you can specify which categories should be tested and which should not.

enter image description here

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

+2
source

Source: https://habr.com/ru/post/949813/


All Articles