Problem
I have a unit test project in Visual Studio 2019. When I click Run All Tests, none of the tests run.
I looked in the Tests output window and saw a message that says:
Test project does not reference any .NET NuGet Adapter. Test discovery or execution might not work for this project.
It’s recommended to reference NuGet test adapters in each test project in the solution.
Note: This is different from the scenario where one test prevents other tests from running.
Solution
- Right-click on your test project
- Click Manage Nuget Packages…
- Browse > search for MSTest.TestAdapter > click on MSTest.TestAdapter in the results > click Install
Now your MSTest unit tests will run.
If it’s still not working, then install / update Microsoft.NET.Test.Sdk and MSTest.TestFramework as well. Note: Thanks to the readers for pointing this out.
This didn’t work for me.
All tests were running, when all of a sudden they started to show in light blue.
I hate Microsoft every day a little more. Their products suck.
Sorry, that sucks. If you check the Tests output window, do you see any errors mentioned?
I see there “Could not find schema information for the element ‘serviceRegistry'”. but on another computer its working well with the same properties “settings” on app.config.
It sounds like this is an element in a custom schema. Try this:
1. Click on app.config
2. XML menu > Create Schema
If that doesn’t work, could you show me the app.config?
Create schema – Its working pretty well. I delete whole .sln from my disk and take latest .sln from server and original report “Could not find schema information for the element ‘serviceRegistry’” does not occurs, but …
If I run test with attribute //[AllowLocalRun] there is no any information about RUN test. I Usualy have to by – “allow locall run to run test”. Is there som more detailed log to check whats VS is doing? Last time I reinstall whole VS 2019 too … I can send some info via email.
I found:
No test matches the given testcase filter `FullyQualifiedName=BonusHandling.BonusHandling_Bahniuk.DebitBonus01|FullyQualifiedName=BonusHandling.BonusHandlingTests.DebitBonus01|FullyQualifiedName=BonusHandling.BonusHandlingTests.DebitBonus02|FullyQualifiedName=BonusHandling.BonusHandlingTests.DebitB…` in C:\TFS\MSCP\PRODUCTS\Medio_AS-OCS\MAIN\Projects\AS-OCS_Services\Test\Autotest\!builds\release\net472\NVision.See.Autotest.TestBonusHandling.dll
Were these tests working in an earlier version of Visual Studio using MSTest?
1 – Make sure your tests have the right attributes for MSTest. Ex: [TestMethod]
2. Make sure you have the updated test packages
Microsoft.NET.Test.Sdk
MSTest.TestAdapter
MSTest.TestFramework
Agree with German.
Microsoft is a midnight horror…
It worked!! Amazing. I have spent 3+ hours trying to solve this issue, none of the other posts worked for me, even the ones on the Microsoft forum. But this did the trick. 🙂 thanks a lot.
I had to update MSTest.TestAdapter and the MSTest.TestFramework from 2.2.2 to 2.2.3. I had to right-click the Solution, then click Manage NuGet Packages, and then update the two packages to 2.2.3.
Note: Comment is paraphrased from an email exchange between the commenter and author (Mak).
There is another case which I saw quite often and is directly related to testing async methods.
[TestMethod]
public async void SDKTest()
=> test DOES NOT run
[TestMethod]
public async Task SDKTest()
=> test is running OK
Thanks Catalin.
A test will only run if it has a correct signature (as required by the test runner).
Errors having to do with the test method signature will appear in the Tests output window, and say something like this:
Same issue brought me here, I tried something I use to have to do while conducting my unit tests via NUnit and it actually resolved this issue. Make sure you have the following 3 Nuget Packages installed on your unit test project/class library:
Microsoft.NET.Test.Sdk
MSTest.TestAdapter
MSTest.TestFramework
Thanks Travis. Originally I only mentioned one package. I updated the page to include all three packages, so people know they need to install / update those if the tests still aren’t running.
Thank you so much Mak! Your solution worked for me! 😀 I only needed to install MSTest.TestAdapter.
Excellent – I’m glad that fixed it for you!
Tried everything. Tests that used to run are not running anymore. They are in “not run” state. No error or other hint….
Alex
Hi Alex. Just to be clear, there’s no errors showing in the Tests output window?
Alex, not sure if you have figured out the problem.
I also have this issue. It turned out that I accidentally removed the signature (TestContext context) from [ClassInitialize] routine, which apparently is required but not used anywhere.
Hope it helps.
Hey Chu, thanks for sharing.
Did you get an error about this? When I’ve run into that problem before, it showed an error. I’m curious to know if you saw an error or if the tests just failed to run with no explanation.
For ref: https://makolyte.com/csharp-test-fails-with-message-classinitialize-has-the-wrong-signature/