2
votes

I have some unit tests in single class "test.cs" and which runs on Visual Studio 2015. Now I want to configure the tests on TFS build. I tried with below configuration and not success.

Builds->Edit Build Definition->Process->Test->1.Automated Tests->1.Test source->Test Source spec=**\*test.cs

How to configure the build definition to run single class tests on TFS build?

1
What test framework are you using? Also, you shouldn't be specifying a .cs file, you should be specifying a test assembly.Daniel Mann

1 Answers

1
votes

Make sure you specify the test assembly as the test source as Deepa mentioned: screen 1

You could then use the criteria to specify the specific class you want to run tests from using:

FullyQualifiedName~NameSpace.Test

screen 2

However pinning your build on a single class to run tests isn't a good practice. If you are using MSTest, consider using test categories:

If you have created automated tests using Visual Studio you can manage these tests by categorizing them with test categories. When you run these automated tests using Visual Studio, Team Foundation Build, or mstest.exe, you can use these test categories to easily select which tests you run. You add test categories as attributes to your test methods.

source: MSDN

These will give you some more flexibility and prevent the build from no longer running test if you rename the class or anything

In your criteria specify the use the category to filter the tests that will run:

TestCategory=MyCategory

screen 3

There is some more info about the criteria you can use in this blog post. The screenshot are taken from a build definition using the GitTemplate.12.xaml template.