Creating Data-Driven Unit Tests
Let’s build on our knowledge of both basic unit testing concepts and the unit testing framework attribute classes and examine how to create a unit test that feeds off of a data source.
Looking back at Listing 8.1, you recall we had to manually define a few invoice objects in the “arrange” section of the test. This works out fine for the limited data we are dealing with here but would quickly become unmanageable if we wanted or needed a more expansive data set. In other words, instead of just testing with a scenario of adding two invoice lines, what if we wanted to add hundreds? And what if we wanted to dynamically populate those line items instead of hard-coding them in the test method? In these cases, you want ...
Get Microsoft Visual Studio 2015 Unleashed, Third Edition 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.