In our project we started to add our unit tests to the same project and kept them together. This gave us the ability to keep things internal which should stay internal. After some iterations we ended up with two conventions:
- Each test class ends with "_Should" so we can read tests easily
- The test stays along with the class in the same namespace (folder)
The second point avoids the annoying duplication and maintenance of a folder structure or a huge namespace "Tests" with dozens of tests. In addition, you can see at a glance which classes don't have a test.
For this cross-relation, NEdifis provides two attributes for this relation.
This makes e.g. a navigation between these classes easier using "go to definition" and gives the opportunity for convention tests to check e.g. if each class has a test or a test fixture is properly named.[TestedBy(typeof(TicketAttribute_Should))] public class TicketAttribute : Attribute { } [TestFixtureFor(typeof(TicketAttribute))] // ReSharper disable once InconsistentNaming public class TicketAttribute_Should { }
Keine Kommentare:
Kommentar veröffentlichen