可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
When I updated Visual Studio to the latest version, 1 of my test projects stopped running tests and outputted this message:
Test project {} does not reference any .NET NuGet adapter. Test discovery or execution might not work for this project. It is recommended to reference NuGet test adapters in each test project in the solution.
UPDATED: I was using MS Test as opposed to any other test frameworks like Nunit or Xunit.
回答1:
Ok, you can add Nuget packages as asked. But you can also try to disable the following setting (Tools->Options->Test):
"For improved performance, only use test adapters in test assembly folder or as specified in runsettings file".
Let me know if it works for you.
回答2:
I had to add the following Nuget packages:
MSTest.TestAdapter
MSTest.TestFramework
Microsoft.NET.Test.Sdk
Visual Studio release notes
回答3:
I had the same issue and none of the answers above worked.
Installing NUnit3TestAdapter V3.10.0
fixed it.
回答4:
If you are using MS Test, try installing
MSTest.TestAdapter
via nuget or
if you are using nunit, install
NUnit3TestAdapter
latest versions via nuget.
After installing please restart the visual studio and then you can see the tests running.
回答5:
I had a very similar issue recently with xUnit, the same outcome, however my fix was due to the fact that previously with lower versions of Microsoft.NET.Test.Sdk you didn't need XUnit.Runner.VisualStudio explicitly installed.
When I updated my Microsoft.NET.Test.Sdk to version 15.9.0 it stopped allowing tests to run until I installed the XUnit.Runner.VisualStudio Nuget.
Now, This may seem blatantly obvious, but, previously it would cope without it and still work. Now, it does not. The same will probably be true of other test platforms. It worked for me.
回答6:
My reputation score does not currently allow me to add this as a comment to the accepted answer. For reference, I've appended version numbers to the nuget packages referenced in csharpsql's answer:
MSTest.TestAdapter v1.3.2
MSTest.TestFramework v1.3.2
Microsoft.NET.Test.Sdk v15.9.0
回答7:
I know that it is stupid, but for me nothing from earlier answers were working. After that I just restart my computer and everything is working correctly :)
(My proble was that one day everything was working correctly and next day it stopped working)
回答8:
For me I felt very foolish after spending hours, trying EVERYTHING, only to find that I had simply forgotten to add the [TestMethod] directive on the unit test method.
回答9:
Since its just a checkbox, Ive tried disabling the following setting before anything else, and it worked!
Tools -> Options -> Test -> "For improved performance, only use test adapters in test assembly folder or as specified in runsettings file"
回答10:
Adding NuGet packages doesn't work for me.
Disable the following setting (Tools->Options->Test): "For improved performance, only use test adapters in test assembly folder or as specified in runsettings file" works.