简体   繁体   中英

Visual Studio Unit Tests Not Found

I am using Visual Studio for a C# application.

In my PC i had installed Gallio, which is a set of test tools (including a test runner). My Unit tests are normal unit tests using the NUnit framework. At my PC, Visual Studio can identify and run the tests.

But when i change PCs, or when i un-installed Gallio from mine, Visual Studio cannot longer find the unit tests giving a message as below:

I know that the fact that my projects cannot be loaded, is because of Gallio. When i was adding a Test class in my project the was set to .被设置为I tried almost everything to make Visual Studio being able to find my test classes again but without any luck.

Does anyone have the same problem? Any ideas why this is happening?

Thank you.

Visual Studio 2010 doesn't have a test runner for NUnit. It can only execute MSUnit tests by default without using an add-on like Resharper. Visual Studio 2012 does now include a runner for NUnit among other testing frameworks.

You have the following options:

  1. Port your tests to use MSUnit; or
  2. Upgrade to Visual Studio 2012; or
  3. Install an add-on like Resharper that has a NUnit runner built in.

The problem is that MSTest and NUnit use different attributes to flag tests:

// MSTest
[TestClass]
public class MsTests
{
   [TestMethod]
   public void MyMethod()
}

// NUnit
[TestFixture]
public class NUnitTests
{
   [Test]
   public void MyMethod()
}

You have to do a swap, or use both if you want it to be available to both frameworks. However MSTest does not like methods with parameters, whereas NUnit does.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM