Test runner runs tests that aren't in fixtures

Using the nightly 5.0 from December 27:

  1. Create an NUnit test file with a public class that does not have a [TestFixture] attribute, but contains a method with a [Test] attribute.  (You may also need to create a different class that does have a [TestFixture] so that it shows up in the Unit Test Explorer.)
  2. Compile the project
  3. Go to "Unit Test Explorer"
  4. Click the assembly containing the class created in step 1.
  5. Click "Run"


Expected behavior: a unit test session will be created that does not include the class that does not have the [TestFixture] attribute

Actual behavior: a unit test session is created that contains the class that does not have the [TestFixture] attribute


This may sound like a strange thing to want.  Our use case is that we have several test fixtures that have different setup code, but identical test code.  We have implemented that by having a base class with several tests, and several subclasses that just do setup.  When Resharper tries to run the base class tests, they fail because the setup hasn't been done.

I've been seeing other, more bizarre behavior in the 5.0 EAP test runner.  For example, database queries run from the test runner are intermittently timing out.  Those same tests run fine in R# 4.5 and in the NUnit test runner.  I can't come up with a reliable reproduction of that, though.

1 comment
Comment actions Permalink

According to http://nunit.org/index.php?p=testFixture&r=2.5.3

Beginning with NUnit 2.5, the TestFixture attribute is optional    for non-parameterized, non-generic fixtures. So long as the class contains    at least one method marked with the Test, TestCase or    TestCaseSource attribute, it will be treated as a test fixture.

Make your base classes abstract, and you'll get what you want!

0

Please sign in to leave a comment.