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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With