Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure Teamcity to ignore some tests

There is a way to configure Teamcity to ignore some tests? I need to run these tests only locally, when they are running in Teamcity, must be ignored.

I'm using nunit.

This could be a directive, attribute, etc.

like image 498
Beetlejuice Avatar asked Nov 23 '15 16:11

Beetlejuice


People also ask

How do I check my TeamCity history?

To view problematic build configurations and tests in your project, open the Project Home page and go to the Current Problems tab. By default, the Current Problems tab displays data for all build configurations within a project.


2 Answers

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

Examples

Do you want to exclude only one test?

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

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

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

Run all tests defined in one class:

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

Forget the full namespace? It's not a problem anymore - use a regular expression:

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

You can also combine these expressions to achieve a desired effect. Run all tests for the class but exlude all methods which contain "BuggyMethod":

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

This approach is much more flexible and avoids any modifications of your code. I don't see a point to use categories anymore, unless your tests are classified using categories.

like image 44
Sergii Zhevzhyk Avatar answered Oct 02 '22 22:10

Sergii Zhevzhyk


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 that category to the NUnit runner's 'NUnit categories exclude:' field in the TeamCity build step.

NUnit categories exclude: LocalOnly

The TeamCity NUnit ignore category field

like image 72
kiprainey Avatar answered Oct 02 '22 21:10

kiprainey