Search code examples
azure-devopsnunitdevopsnunit-3.0vstest

How to run VSTest.Console a dynamic number of projects?


In my quest of setting up our CI/CD Pipeline on Azure DevOps(previously on Jenkins), I'm trying to execute all the tests(NUnits) in my solution.

Currently, the command line is :

vstest.console.exe "Solution\MySolution.sln" /Settings:"testSettings.runsettings" /Logger:"trx" /TestAdapterPath:"Solution\packages\NUnit3TestAdapter.3.12.0\build\net35"

Previously, on Jenkins, we were executing this:

nunit3-console.exe Solution\MySolution.sln --config=Debug --agents=1 --result=TestResult.xml;format=nunit2 --timeout=900000 --workers=1

Which was working find and was able to find all the tests. But I don't think it's supported in the Azure DevOps. Now, I'm checking the documentation: https://learn.microsoft.com/en-us/visualstudio/test/vstest-console-options?view=vs-2017#general-command-line-options

But I can only find a way to list all the tests DLL. I don't find this acceptable, because:

  1. I don't find this robust, if somebody adds a new test assemblies, rename one, ... We will just have no tests results for those tests and this will easily be going under the radar(we have already more than 9000 tests)
  2. It makes a lot of DLL to specify here, there has to be a smarter way?

So my question is there a way to execute all tests present in a solution? If not, is it at least possible to use some kind of pattern? Like *.Test.dll


Solution

  • You could use Visual Studio Test task instead of command line to run NUnit tests. Use this task to run unit and functional tests (Selenium, Appium, Coded UI test, and more) using the Visual Studio Test Runner. Other than MSTest-based tests, test frameworks that have a Visual Studio test adapter, such as xUnit, NUnit, Chutzpah, can also be executed.

    The test files support multiple lines of minimatch patterns:

    enter image description here