Why does visual studio 2012 not find my tests?

后端 未结 30 3166
盖世英雄少女心
盖世英雄少女心 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:08

    I know this is an older question but with Visual Studio 2015 I was having issues where my newly created test class was not being recognized. Tried everything. What ended up being the issue was that the class was not "included in the project". I only found this on restarting Visual Studio and noticing that my test class was not there. Upon showing hidden files, I saw it, as well as other classes I had written, were not included. Hope that helps

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

    I have Visual Studio 2012 and i couldn't see the Tests in Test Explorer,

    So I installed the following: NUnit Test Adapter

    That fixed the issue for me !

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

    I hit the same problem while trying to open the solution on a network share in VS2013 Ultimate.

    I corrected the problem by turning on

    Control Panel -> Internet Options -> "Security" Tab -> Click "Local intranet", click on sites and make sure "Automatically detect intranet network" is ticked.

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

    None of the solutions here helped me. The tests wouldn't be discovered for one solution whereas another solution referencing the same projects worked fine. I finally solved this by deleting the solutionname.v12.suo file.

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

    I had same issue, but a bit different.

    I was using visual studio 2012. For some reason, only the tests of the initial generated file was running. But tests in another file were not running. Tried out different solutions posted here, did not work.

    Finally I figured out that I had a private method in the test class which was the first method inside the class. I just moved the private method after a test method; so now, a method with [TestMethod] attribute is the first method inside the class. Strange, but now it works.

    Hope this helps someone someday.

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

    Tests do not like async methods. Eg:

        [TestMethod]
        public async void TestMethod1()
        {
            TestLib oLib = new TestLib();
            var bTest = await oLib.Authenticate();
    
        }
    

    After doing this:

        [TestMethod]
        public void TestAuth()
        {
            TestMethod1();
        }
    
        public async void TestMethod1()
        {
            TestLib oLib = new TestLib();
            var bTest = await oLib.Authenticate();
    
        }
    

    It saw the test.

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