Visual Studio 2013 doesn't discover unit tests

前端 未结 30 1967
余生分开走
余生分开走 2020-11-28 21:46

I have a simple solution in visual studio 2013 that is composed by one web project, one library project and one unit test project. When I open the solution and try to run th

相关标签:
30条回答
  • 2020-11-28 22:25

    for me it was changing 'solution configurations' to Debug (instead of Release).

    0 讨论(0)
  • 2020-11-28 22:26

    Some things I've noticed I have to do from time to time to get tests to show up properly.

    1. If your solution is in a protected drive that you need administrator access to read/write, sometimes only a portion of the tests come up. Definitely run VS as administrator in that case.

    2. If your solution is 64 bit, make sure that Test > Test Settings > Default Processor Architecture is set to x64. Sometimes it gets set to x86. Set it to x64, then rebuild.

    3. Sometimes just restarting Visual Studio does the trick because the test explorer will start up again.

    4. Don't forget to actually build the test project/solution. (If you want it to get built with the rest of the projects, right-click on your solution > Properties > Configuration Properties > Configuration > check the "Build" box for your test project)

    5. Ensure the tests are in a public section of your test class

    0 讨论(0)
  • 2020-11-28 22:27

    If you using NUnit, make sure to download NUnit Adapter first.

    Go to Tools → Extensions and Updates… → Online → search for "NUnit Test Adapter".

    0 讨论(0)
  • 2020-11-28 22:27

    XUnit users may notice Test Explorer window no longer lists any tests. To make tests discoverable again try this important tip, highlighted below.

    If you're having problems discovering or running tests, you may be a victim of a corrupted runner cache inside Visual Studio. To clear this cache, shut down all instances of Visual Studio, then delete the folder %TEMP%\VisualStudioTestExplorerExtensions. Also make sure your project is only linked against a single version of the Visual Studio runner NuGet package (xunit.runner.visualstudio).

    0 讨论(0)
  • 2020-11-28 22:28

    I'd managed to add mine as

    public static void TestMethod1(){}
    

    started working once I removed static....

    0 讨论(0)
  • 2020-11-28 22:30

    Make sure your test class is public so it can be found. And if you're referencing another class, make sure of the same.

    Also, sometimes if you have no Asserts or you're not decorating the test with a [TestMethod], a test might not be recognized.

    2 more things: 1) Async unit tests act funny at best, and none at all at worst. Have a look at this article by Stephen Cleary and keep from there if it interests you.

    2) If you use NUnit and you run into the same issues, keep in mind it's [TestCase] for Nunit, instead of [TestMethod]

    Having said the above, here's an article I've posted on the code project, with both MSTest & NUnit, in case you want to give it a spin and make sure you're not missing anything.

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