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

前端 未结 18 1589
不知归路
不知归路 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 11:58

    this is typical problem i have faced too. but the easiest solution I followed as my own is...just to build the project once and rebuild it again. so that you can resolve it.

    0 讨论(0)
  • 2020-12-24 11:59

    This could be another reason. Check whether the solution is running on 64bit. If so change it to x86.

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

    The fix is simple, even though it shouldn't be needed, if Visual Studio worked as it should.

    To sum up what others have contributed, particularly in this article, here's what ultimately worked for me:

    • Use the Configuration Manager to make sure your test project is selected to build in whatever configuration and platform you're using (ex: configuration=Debug and platform=x86)
    • Make sure your method belongs to a [TestClass] and that it's both marked [TestMethod], and NOT using the attribute [Ignore]
    • Use Test View to find your test. Test View
    • Open your Properties window (F4), and make sure your test is enabled Enabled
    0 讨论(0)
  • 2020-12-24 12:00

    The original poster did do this, but I arrived here after not having done this:

    Be sure that [TestClass] is declared at the top, public in scope:

    namespace XYZ.API.Repository.Tests
    {
        [TestClass()]
        public class ClientTests
        {
    
    0 讨论(0)
  • 2020-12-24 12:01

    Possibly a bit late, but this question googles up well, I thought I'd throw some crumbs in for future googlers.

    Bryan Cook suggests checking the ProjectTypeGuids in his blog post about Manually creating a MS Test Project. Apparently the magic GUIDs you need are {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} for c# and {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{F184B08F-C81C-45F6-A57F-5ABD9991F28F} for VB. See his blog post for more details.

    In case the blog post ever goes away you need to add the following element in the main property group in the csproj file:

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

    Had this same issue but reading over the previous answers, everything looked good.

    In my case, I had just run the test suite made a small change, built the solution and tried to run the test. No go. I tried building a couple more times and looking for problems other people had tried. Still no go.

    I hit enter in one of my test methods to add a new and hit F6 to build the solution and clicked run Unit Tests.

    Bingo! Everything ran smoothly.

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