How to configure Teamcity to ignore some tests

Is there a way to configure Teamcity to ignore some tests? I need to run these tests only locally, when they work in Teamcity, should be ignored.

I am using nunit.

It can be a directive, attribute, etc.

+5
source share
2 answers

You can do this by adding test categories to your tests.

[Category("LocalOnly")] [Test] public void MyLocalTest() { // Code omitted for brevity } 

You can then add this category to the NUnit "NUnit categories exclude:" field during the TeamCity build phase.

 NUnit categories exclude: LocalOnly 

TeamCity NUnit ignore category field

+10
source

TeamCity 9.1 supports NUnit 3 and opens up many other possibilities to select tests to run or filter them. I would recommend using --where=EXPRESSION , which allows you to use Test Selection Language . Now you can even use regular expressions to indicate which tests you want to run or exclude.

<strong> Examples

Do you want to exclude only one test?

 --where="method != 'TestName'" 

Do you want to exclude only one test? Do not remember the name exactly, but something with "BuggyMethod" ( ~ means that the regular expression is involved):

 --where="method !~ 'BuggyMethod'" 

Run all tests defined in one class:

 --where="class == 'My.Namespace.ClassName'" 

Forget the full namespace? This is no longer a problem - use regex:

 --where="class =~ 'ClassName'" 

You can also combine these expressions to achieve the desired effect. Run all tests for the class, but exclude all methods that contain "BuggyMethod":

 --where="class =~ 'ClassName' and method !~ 'BuggyMethod'" 

This approach is much more flexible and avoids any modifications to your code. I no longer see the point of using categories if your tests are not categorized.

+2
source

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


All Articles