Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 207
Stephen Wilson Avatar asked Oct 19 '25 15:10

Stephen Wilson


1 Answers

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.

like image 104
Ross Gurbutt Avatar answered Oct 21 '25 05:10

Ross Gurbutt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!