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

前端 未结 30 1753
广开言路
广开言路 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:12

    I ran into the same problem in VSTS with .Net 4.6.2. If you are seeing this from your VSTS console output, the workaround provided by @Sushil still works in VSTS and is needed. Unfortunately the "Test Assemblies" task provided by Microsoft passes, so you really don't even know there is a problem unless you check the output and find none of your tests actually executed!

    0 讨论(0)
  • 2020-12-05 04:13

    In my case, I had to:

    1. Convert test project to netcore 2.0 (was netstandard 2.0)

    2. Add nuget package xunit.runner.visualstudio

    Reference: http://www.neekgreen.com/2017/11/20/xunit-no-test-is-available/

    0 讨论(0)
  • 2020-12-05 04:14

    Using .Net Core with a build pipeline in TFS 2017, my Visual Studio Test step was passing without actually executing any tests. Had to edit the step, "Advanced Execution Options" -> "Other console options" to include:

    /framework:".NETCoreApp,Version=v2.0"
    

    (That field also contains /platform:x64)

    0 讨论(0)
  • 2020-12-05 04:16

    Make sure that you've got the "Microsoft.NET.Test.Sdk" nuget installed.

    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2020-12-05 04:17

    This is just to recap the solution brought forward by @Sushil earlier.

    This is a known issue in Team Foundation Server 2015 RTM + Update 1 and will be fixed in Update 2, reference.

    There is a workaround described by @Sushil here, which includes adding a .runsettings file that forces the test runner to older .Net framework (please not that you have to specify it through the "Add/Edit Test Run" dialog as adding it directly in the build process editor will be ignored).

    0 讨论(0)
提交回复
热议问题