Tests brevity

Through data-driven tests, it is easier to reduce redundancy while still maintaining comprehensive test coverage. This is because test code duplication can be avoided. Tests that would have been traditionally duplicated to test different datasets can now be reused for different datasets. When there are tests that have similar structures but with dissimilar data, this is an indication that the tests can be refactored as data-driven tests.

Let's review the CarLoanCalculator class and the corresponding LoanCalculatorTest test class in the following snippets. This will provide a valuable insight into why data-driven testing can simplify testing while providing brevity of code when compared with the traditional approach to writing ...

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.