Visual Studio 2013 doesn't discover unit tests

前端 未结 30 1963
余生分开走
余生分开走 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:23

    Try building all projects as MSIL (Any CPU) instead of x86/x64. Worked for me strangely

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

    Sorry for adding to the long list, but I had a completely a different problem. First, I would like to mention I discovered my issue when clicking 'Run All' in the Test Explorer and then watching the build output window in Visual Studio. You have to actively watch it, as afterwards the message disappears.

    As for the issue, it looks like during the scanning of the tests, the DLL gets loaded and its test types are enumerated. This causes the references to be loaded and if any failure occurs during this process, the tests will not be shown in the explorer. I had two issues preventing the test DLL to be successfully loaded:

    • There was still a binding redirect left in the config file (redirecting to a version lower version NHiberate than what was referenced in the test project).
    • A conflicting assembly reference (2nd level references not being able to load). AsmSpy is btw a great tool to hunt for these.
    0 讨论(0)
  • 2020-11-28 22:23

    If you load a Visual Studio (VS 2015 Community in my case) solution from a network share or My Documents directory that is part of a share, you will get into this trouble. I solved it by moving the solution and its underlying projects to a local folder.

    0 讨论(0)
  • 2020-11-28 22:23
    • I know that the unit tests are not found if the solution is not built, so that is something to try (Build the solution), but that solution is like the help desk asking if your computer is plugged in...
    • After a clean rebuild did not fix the problem for me, running a full batch build did fix it.
    0 讨论(0)
  • 2020-11-28 22:24

    I had the same issue but none of the other solutions worked. Turns out that I was using the NUnit 3 framework with the 2 adapter.

    If you're using NUnit 3, go to Extensions and Updates and install the NUnit3 Test Adapter.

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

    For future googlers I had a rare scenario that caused this.

    On my base test class I had a property named TestContext. This interfered with MSTest's reserved TestContext property causing all my tests to be hidden from VS/Resharper except one (which did not inherit from the base).

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