Structuring unit tests with xUnit

Similar to the manner in which an application's code base is structured to allow easy readability and for effective source code maintenance, unit tests should be structured. This is to facilitate easy maintenance and quick running of tests using the test runners from Visual Studio IDE.

A testcase is a test class containing test methods. It is usually common to have one test class per class under test. Another common practice of structuring tests among developers is to have a nested class for each method being tested or to have one base test class for the class under test and one subclass for every tested method. Also, there is the test class per feature approach, where all the test methods that collectively ...

Get C# and .NET Core Test Driven Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.