Visual Studio not finding unit tests

0

I've created a new project containing only a basic unit test. But no matter what I do, VS simply doesn't run the test. I presume it doesn't find it.

namespace UnitTestProject1
{
  [TestClass]
  public class UnitTest1
  {
    [TestMethod]
    public void TestMethod1()
    {
      Debug.WriteLine("qwerty");
      Assert.AreEqual(1, 2);
      throw new Exception("Kaboom!");
    }
  }
}

Being so simple, no dependencies are needed.

Most of the time when building (using "Run All" in Test Explorer, main menu under "Build", main menu under "Test") VS says the project built fine, but says nothing more.

But if I first clean the project then do "Run All" in Test Explorer, then VS gives this...

------ Discover test started ------
Could not load file or assembly 'file:///Z:\Dev\x\Xer\UnitTestProject1\bin\Debug\UnitTestProject1.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
========== Discover test finished: 0 found (0:00:00.149) ==========

...but the .dll does exist in that location. ("Run All" builds it.)

I've cleared caches according to: Visual Studio 2015 does not discover unit tests

Using Microsoft Visual Studio Community 2015, Update 3.

I'm at a complete loss. What am I missing?

c#
visual-studio
unit-testing
vs-unit-testing-framework
asked on Stack Overflow Jan 4, 2017 by Peter Thönell • edited May 23, 2017 by Community

1 Answer

0

Take a look at the following link: Could not load file or assembly Operation is not supported.

It looks like you need to add the <loadFromRemoteSources enabled="true" /> tag under the runtime tag in your project config.

answered on Stack Overflow Jan 4, 2017 by Mark Atkinson • edited May 23, 2017 by Community

User contributions licensed under CC BY-SA 3.0