Stephen Wilson
Stephen Wilson

Reputation: 1514

Run only certain tests in Azure DevOps

I have inherited an ASP.Net (Non .Net Core) project with a large amount of tests all contained in one C# test project. I want to run the unit tests on Azure DevOps as a build step but the issue I face is that the unit tests are inside a sub-folder of the project and in other folders are other tests that I do not wish to run.

My question is, can I configure the task: VSTest@2 to only run the tests inside a specified folder within the Tests project?

Thanks in advance.

Upvotes: 4

Views: 7016

Answers (2)

Ross Gurbutt
Ross Gurbutt

Reputation: 1029

In you build yaml file (or via the azure devops interface) you can set:

testFiltercriteria:ClassName~MyTestClassName

You could try seeing whether wildcards work in this to allow you to say everything in x folder. The documentation for this property is quite sparse.

See here for a list of the full set of properties available to VSTest@2.

See here for documentation on the test case filters that can be applied.

See here for a list of the additional command line options (not needed for this, but a useful resource.)

Alternatively, the testFiltercriteria can be used to specify the FullyQualifiedName (name including namespace). Filtering by this, you can use "~" to say contains rather than equals, so if your folder structure roughly matches your namespace structure, then this would also work.

Upvotes: 8

Glenn Ferrie
Glenn Ferrie

Reputation: 10410

You can see a input box for applying filters in the Pipeline Step for 'Visual Studio Test' in your Azure DevOps Pipeline. screenshot

Upvotes: 0

Related Questions