nikkatsa
nikkatsa

Reputation: 1811

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:

"No Tests were run because no tests were loaded or the selected tests are disabled"

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 Test Type was set to Gallio. 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.

Upvotes: 0

Views: 6015

Answers (2)

Dominic Zukiewicz
Dominic Zukiewicz

Reputation: 8444

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.

Upvotes: 1

Jack Hughes
Jack Hughes

Reputation: 5664

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.

Upvotes: 5

Related Questions