2

When analyzing the different options to organize unit tests in NUnit, I understood it as mainly of three types. 1.Test per Fixture 2.Class 3.Feature

Can anyone share some good reference which will provide an insight on this? ReferenceI am confused, the site referenced here explains NUnit or any other testing framework?

What are the constraints to be considered when selecting a pattern among the three?

1 Answers1

1

For unit tests, we generally create one test class for every non-trivial class in our code. UsersDal will have a matching UsersDalTests, LicenseValidation a matching LicenseValidationTests, etc. This makes it easy to locate the tests when modifying a class. Tests per feature wouldn't make sense, as one top-level feature likely hits multiple classes.

If you were using NUnit to drive integration tests, then a per-feature structure would be appropriate.

Pedro
  • 12,032
  • 4
  • 32
  • 45
  • Can you suggest any links or reference which explains this in detail? I could not find any. –  Apr 19 '16 at 22:29
  • Don't know of any at the moment. Our current pattern was partially figured out through trial and error. For instance, if you have unit tests based on features, but are refactoring a class, the tests associated with that class will be scattered across multiple features. You don't want the tests being so hard to maintain that the developers choose to delete or ignore them instead of keeping them working. – Pedro Apr 20 '16 at 14:27