tags:

views:

42

answers:

1

I want to test one method that has a high cyclomatic complexity (sigh) and I would like to have a class within test class so that a method test class appears as a node in the tree. Is it possible with Nunit and how?

 MyEntityTests
 |
 L_ MyComplexMethodTests
    L when_some_condition_than
    L when_some_other_condition_than

[TestFixture]
public class MyEntityTests
{
  [TestFixture]
  public class MyComplexMethodTests
  {
    [Test]
     public void when_some_condition_than() {} 
   etc.....

  }
}
A: 

It sounds like you have one class you want to test, but you have two sets/types of tests to run. The easiest way to do that might be to create two TestFixtures, one for each. Another way to do it is to place each test into a Category.

Edit: If all of the tests are on the same method, one option is to use the TestCase attribute and specify the parameters for each test (as well as the expected result.) The GUI will nest each set of TestCase parameters under a single instance of that test name. This assumes all of your tests will behave similarly, meaning the same basic Asserts or ExpectedExceptions.

Pedro