I am in the process of upgrading our existing solution to .Net 4.6.1 and have been unable to get our unit tests to run during a server build. Locally they run as expected an
This question is obviously being found by people with a range of scenarios, my answer will cover running XUnit tests on a .NET Core project using build pipeline on Azure DevOps but may help others too.
otherConsoleOptions: '/framework:.NETCoreApp,Version=v3.1' to the inputs of your VSTest@2 step (with the version number set to whatever version of .NET Core you are using). See this documentation for more info.failOnMinTestsNotRun: true so that the build pipeline will report a failure if zero tests are run.The library 'hostpolicy.dll' required to execute the application was not found. You can solve this by changing your filter from the default **\*test*.dllto **\*test.dll (note the removed asterisk), or some other pattern which will match your test project's DLL. The reason for this is that XUnit places a file called testhost.dll in the output directory, as explained in this github issue.If you are using the older pipelines which do not use yaml, the same options should be available. This answer covers adding the framework, I assume there will also be an option to "Fail the task if a minimum number of tests are not run" or something similar.