0
votes

Because you can't set a Test Category on a Test Class with MSTest, I've opted to do something similar in the name, postfixing test classes with ...IntegrationTests whenever they contain slow running tests.

In the Visual Studio Test Explorer I can exclude these tests by using:

-class:IntegrationTests

However, in TeamCity, this option doesn't work. I'm using the VSTest 2017 test engine version in the latest version of TeamCity. However, it seems it only has a TestCaseFilter option that seems to be missing the option to exclude tests in a certain class?

I used this VSTest.ConsoleRunner documentation and this post about the TestCaseFilter to reach that conclusion. I've also read through the runsettings file documentation to see if it contains any info, but no luck.

My goal is to have 1 TeamCity step that runs all tests in classes that are not "marked" as being slow, and another followup step with the tests in classes that are marked.

The only workaround I currently see would be to split all of my test projects into two projects, and move those integration test classes to separate assemblies. I'd rather not do that.

Bottom line: how to exclude tests in classes where the class name contains a specific string?

1

1 Answers

1
votes

TestCategory attribute can be used at the class/assembly level. See here: https://blogs.msdn.microsoft.com/visualstudioalm/2017/02/25/mstest-v2-now-and-ahead/.

Also, please see same twitter thread here: https://twitter.com/pvlakshm/status/844905609409564672