Good naming convention for multiple NUnit Setup methods

199 Views Asked by At

Prior to NUnit 2.5 you could only have one [SetUp] method across the inheritance hierarchy, so you always knew what to call it: SetUp().

Now, however, you can have multiple SetUps, and it's especially useful to have one at each level of the hierarchy, mimicking inherited constructors. The trick is what to call them. Adorning the methods with the [SetUp] attribute is what matters, so they can really be named anything.

I started out using SetUp() for the base class and SetUpLocal() for the inherited class, but that quickly fell apart as soon as I wanted to give the base class a parent.

The most easily-enforced standard seems to be using the class name at each level, but SetUpFooRespositoryTestsBase() and SetUpDeleteFooRespositoryTests() just look so much clunkier than a nice, simple SetUp().

Does anyone else have a standard that works well for them? I'd like to get this right before I create 50 test classes.

0

There are 0 best solutions below