nunit-vs-adapter
nunit-vs-adapter copied to clipboard
NUnit test cases not run from inherited class.
I found a stackoverflow question that discusses this very issue. That question has to do with the ReSharper test runner, but the same buggy behavior exists in the NUnit VS adapter.
The NUnit standalone runner works correctly, so this bug is probably not in NUnit Core.
I'm a bit surprised that this has not been reported before, or fixed yet, as abstract test fixtures are getting increasingly popular.
Any workarounds (or even better, a quick fix) are greatly appreciated, this technique is a core part of our current test plan.
EDIT: It turns out that running tests explicitly from the test class node in Test Explorer does run all the tests and test cases in the base class.
However:
-
Running tests using CtrlR+CtrlT (TestExplorer.DebugAllTestsInContext) runs only the [Test]'s in the base class, not the [TestCase]'s.
-
Double clicking on a such a TestCase in Test Explorer does not navigate to the correct file and line in the abstract text fixture.
This reduces the severity to a major inconvenience, but at least there is a workaround. A fix is still very appreciated.
Both the priority and the assignment to the fix-in-both milestone are dependent on confirming the bug.
@OsirisTerje I moved this from 3.0-Only because it seemed like it should either be fixed in both or closed if not confirmed. Is there some reason not to fix in 2.0 if confirmed? Note that I'm the one who gave it a priority:normal - you may not agree.
Hmmmm, I was about to open an issue, but perhaps is the same problem, what I discover is that if I have an abstract base test fixture class on one assembly and the derived test class in a different assembly and namespace then the tests are not found (tested on 3.5 with 3.4.1 Vs runner)
Is it only if the base is abstract? Does it still happen if the derived test has a [TestFixture] attribute?
@fsalas Can you show a simple example? Things that could change the outcome include:
- which of the two classes has the TestFixtureAttribute (it doesn't belong on the abstract class, even though it works in some situations)
- which of the two classes contains tests
Also, could you clarify if only some tests (those in the base) are not found or if the entire class is skipped.
If your info leads to confirming the bug, it will be one step closer to being fixed.
I believe I am having the same issue. It appears to be caused by having two levels of abstraction. This is how I have it setup. In the code below, Test2 works fine and I can verify that both the OneTimeSetUp and the OneTimeTearDown methods get called. However, If I run Test1, it calls the OneTimeSetUp and then immediately calls the OneTimeTearDown without ever entering the Test1 method.
public abstract class TestBaseClass
{
[OneTimeSetUp]
public void OneTimeSetup()
{
//Run setup stuff
}
[OneTimeTearDown]
public void OneTimeTeardown()
{
//Run teardown stuff
}
}
public abstract class GlobalTests : TestBaseClass
{
[Test]
public void Test1()
{
//Do test stuff
}
}
[TestFixture]
public class ModuleSpecificTests : GlobalTests
{
[Test]
public void Test2()
{
//Do test stuff
}
}
@Retik When "running Test2" how do you do it? What version of the adapter are you using?
Sorry, I just realized my mistake. I had other tests in my GlobalTests class that were getting run successfully so I noticed that the test that was failing to run had a parameter in it without a [TestCase]. My mistake, everything seems to be working correctly.