Visual Studio 2019: MSTest unit tests are not running in Test Explorer

Problem

I have a unit test project in Visual Studio 2019. When I click Run All Tests, none of the tests run.

Visual Studio unit tests showing blue (!) indicating they didn't 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.

Solution

  1. Right-click on your test project
  2. Click Manage Nuget Packages
  3. Browse > search for MSTest.TestAdapter > click on MSTest.TestAdapter in the results > click Install
Adding the MSTest.TestAdapter package with the Nuget Package Manager UI

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.

20 thoughts on “Visual Studio 2019: MSTest unit tests are not running in Test Explorer”

  1. 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.

    Reply
      • 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.

        Reply
        • 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?

          Reply
          • 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.

  2. 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

    Reply
    • 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

      Reply
  3. 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.

    Reply
  4. 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).

    Reply
  5. 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

    Reply
    • 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:

      UTA007: Method does not have correct signature. … if you are using async-await in test method then return-type must be Task.

      Reply
  6. 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

    Reply
    • 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.

      Reply
  7. Thank you so much Mak! Your solution worked for me! 😀 I only needed to install MSTest.TestAdapter.

    Reply
  8. Tried everything. Tests that used to run are not running anymore. They are in “not run” state. No error or other hint….

    Alex

    Reply

Leave a Reply to Alex Cancel reply