I have a base test class containing some test cases and some ordinary tests:

[TestFixture]
public abstract class TestBase
{
  [TestCase(1)]
  [TestCase(2)]
  [TestCase(3)]
  public void TestA(int value)
  {
    // Perform test
  }

  [Test]
  public void TestB()
  {
    // Perform test
  }
}

These tests are run from child classes which set up the environment in different ways. The child classes only contains setup methods, no tests.

[TestFixture]
public class LocalDatabaseTest : TestBase
{
  [SetUp]
  public void SetUp()
  {
    // Set up environment to use local db
  }
}

I'm using ReSharper 6.1.1000.82 to run all tests in LocalDatabaseTest, but only the ordinary tests are run. The tests using TestCase does not get any result. If I select Run All on TestA in the TestBase class, all test cases are run (including the other child classes). I'm using NUnit 2.6.2.12296. Any ideas on what I've done wrong?

有帮助吗?

解决方案

You've done nothing wrong.

If you open your test dll via NUnit test runner you will see all test are running successfully.
(I just verified your code with NUnit 2.6.2).

Regarding the reason of ignoring parameterized tests on Resharper: It seems there is some issue with Resharper test runner which causes such behavior.
So, my suggestion is to use NUnit to run parameterized tests.

Btw, Resharper 7 has better support NUnit parameterized tests. And probably this issue won't appear in the latest Resharper version.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top