Why does visual studio 2012 not find my tests?

后端 未结 30 3163
盖世英雄少女心
盖世英雄少女心 2020-12-07 10:51

I have some tests that use the built in Microsoft.VisualStudio.TestTools.UnitTesting, but can not get them to run.

I am using visual studio 2012 ultimat

相关标签:
30条回答
  • 2020-12-07 11:03

    Since the project is on a shared drive as the original poster have indicated. VS.NET needs to trust network location before it will load and run your test assemblies. Have a read of this blog post.

    To allow VS.NET to load things of a network share one needs to add them (shares) to trusted locations. To add a location to a full trust list run (obviously amend as required for you environment):

     caspol -m -ag 1.2 -url file:///H:/* FullTrust
    

    To verify or list existing trusted locations run:

     caspol -lg
    
    0 讨论(0)
  • 2020-12-07 11:04

    I had this problem when upgrading my solution from Microsoft Visual Studio 2012 Express for Web to Microsoft Visual Studio 2013.

    I had created a Unit Tests project in 2012, and after opening in 2013 the Unit Test project wouldn't show any tests in the tests explorer. Everytime I tried to run or debug tests it failed, saying the following in the output window:

        Failed to initialize client proxy: 
        could not connect to vstest.discoveryengine.x86.exe
    

    I also noticed that on debugging the tests, it was launching an instance of Visual Studio 2012. This clued me into the fact that the Unit Tests project was still referencing 2012. Looking at the test project reference I realised it was targeting the wrong Microsoft Visual Studio Unit Test Framework DLL for this version of Visual Studio:

    C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll
    

    I changed the version number from 11.0 to 12.0:

    C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll
    

    I rebuilt all and this fixed the issue - all tests were found in the Test Explorer and now all tests are found and running perfectly.

    0 讨论(0)
  • 2020-12-07 11:05

    I found the best way to troubleshoot this issue is to create a .proj msbuild file and add your unit test projects which you hare having an issue into this file and execute the tests using the command line version of mstest. I found a small configuration issue in my app.config which only appeared when running the tests from mstest - otherwise the test project built just fine. Also you will find any indirect reference issues with this method as well. Once you can run the Unit test from the command line using mstest you can then do a clean solution, rebuild solution and your test should be discovered properly.

    0 讨论(0)
  • 2020-12-07 11:05

    In My case it was something else. I had installed a package and then uninstall it and reinstall an earlier version. That left a residual configuration/runtime/asssemblyBinding/dependencyIdentity redirecting in my app.config. I had to correct it. I figured it out by looking at the Output window and selecting "Tests" in the drop down. The error message was there. This was a pain... I hope it helps someone else.

    0 讨论(0)
  • 2020-12-07 11:05

    It looks like NUnit Framework 2.6.4 does not work well with NUnit Test Adapter. In the website it mentions the test adapter will only work with NUnit Framework 2.6.3.

    This was my problem: 1. I had downloaded NUnit and NUnit Test Adapter separately through Nuget in the VS2012. Somehow NUnit got updated to 2.6.4 Suddenly i did not see my test cases listed.

    Fix:

    1. Uninstall Nuget and Nuget Test adapter

      a. Go to Tools> Nuget > Nuget Pkg manager > Manage Nuget Pkg for Solution

      b. List installed packages

      c. Click manage

      d. Un-check your projects

    2. Install NUnit Test Adapter including NUnit 2.6.3 Framework

    3. Clean/Rebuild solution

    4. Open Test > Test Explorer > Run All

    I see all the test cases

    Hope this helps

    0 讨论(0)
  • 2020-12-07 11:06

    I've updated VS 2012 to the Latest Update . ie visual studio update 3. That fixed the issue for me.

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