MSTest: No tests are run because no tests are loaded or the selected tests are disabled

前端 未结 18 1591
不知归路
不知归路 2020-12-24 11:55

I have a c# solution with the following structure:

mySolution
  myProject
  myProject.MSTests
    References
      Microsoft.VisualStudio.QualityTools.UnitTe         


        
相关标签:
18条回答
  • 2020-12-24 12:09

    Another one for googlers using NUnit, especially those who have migrated from MS Unit test to NUnit. Please remove the project type Guids that are identifying the project as MS Test project from the project file.

    <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
    
    0 讨论(0)
  • 2020-12-24 12:13

    Another one for the googlers - this one turned out to be my problem, and it's embarrassingly boneheaded of me. Make sure that your test project is set to build in whatever solution configuration you're using. If the test assembly isn't being built, VS won't be able to find any tests in the non-existent assembly, and you'll bang your head against the wall for a while :-)

    0 讨论(0)
  • 2020-12-24 12:15

    Do you have a VSMDI file in your solution? I believe this file is required (NOT VERIFIED).

    0 讨论(0)
  • 2020-12-24 12:20

    None of the other answers worked for me. I kept getting the following message in the output window:

    ------ Discover test started ------
    ========== Discover test finished: 2 found (0:00:00.1310428) ==========
    No tests found to run.
    

    In my case, the problem only occurred after I created a new configuration called 0-Local. I had to add <DebugSymbols>true</DebugSymbols to the relevant section of my csproj file, so it looks like this:

    <PropertyGroup Condition="'$(Configuration)|$(Platform)' == '0-Local|AnyCPU'">
      <DebugSymbols>true</DebugSymbols>
      <OutputPath>bin\0-Local\</OutputPath>
    </PropertyGroup>
    
    0 讨论(0)
  • 2020-12-24 12:21

    I was receiving the same message and it turned out to be that I had my unit test project on a network drive. Once I moved it local it ran fine. Just something to try if you get this error. John

    0 讨论(0)
  • 2020-12-24 12:22

    When you run into this issue, in Visual Studio, you have to create a Test Project. 1. Select Test in Tool bar and choose "New Test". Create your project and at this point create your test method. It should work after this point.

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