No test found. Make sure that installed test discoverers & executors, platform & framework version settings are appropriate and try again

前端 未结 30 1831
广开言路
广开言路 2020-12-05 04:00

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

30条回答
  •  星月不相逢
    2020-12-05 04:16

    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.

    • Ensure you have the XUnit test adapters installed from nuget as per this answer.
    • In the yaml for your build pipeline, add 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.
    • While this is not mandatory, I would recommend also adding failOnMinTestsNotRun: true so that the build pipeline will report a failure if zero tests are run.
    • If you run a build at this point, you may find that your tests run but the pipeline then gives the error 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.

提交回复
热议问题