NUnit test cases not run from inherited class
Asked Answered
O

1

10

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?

Outstanding answered 24/1, 2013 at 16:1 Comment(0)
U
7

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.

Ursine answered 24/1, 2013 at 21:12 Comment(2)
Ok, looks like its time to upgrade to ReSharper 7 then... :-)Outstanding
This is not fixed in 7.1 in VS 2012. However, +1 for pointing that out. It was driving me nuts why it was showing inconclusive for no reasonGallimaufry

© 2022 - 2024 — McMap. All rights reserved.