My slides from the ERDDUG June 2011 meeting. The slides cover Unit Testing, what makes code hard to test and applying polymorphism to wire your application up differently in testing and production configurations.
2. Types of Testing Scenario Testing You pretend to be a user. The app gets tested as a single unit. You’re testing by runningstatic void Main() Can’t test all edge cases. Functional Testing Sub-systems of the app get tested in isolation, e.g. by substituting databases with XML data sources. Ensures that groups of classes interact with each other correctly. When green – sure the subsystem works correctly. When red – easier to reproduce, but still need a debugger to find the exact problem.
3. Unit Testing Tests each individual class in isolation. Can simulate all edge cases and error conditions Fast – only instantiates the part of the app that’s actually needed for the test When green – know the class is OK in isolation, but haven’t tested interaction with others classes. (Functional test) When red – know we can reproduce the error easily.
14. Unit Testing Classes Other Class File System CPU Intensive Seam Other Class Other Class Class Under Test Test Driver Other Class Destructive operation Other Class Other Class Other Servers Object Lifetime and Calling Object Instantiated Object Passed In Global Object
15. Unit Testing Classes Seam (Polymorphism) Other Class Friendly Class Under Test Test Driver Other Class Friendly Other Class Object Lifetime and Calling Friendly Object Instantiated Object Passed In Global Object
16. Unit Testing Classes Seam Dependency Injection Friendly Class Under Test Test Driver Friendly Friendly Object Lifetime and Calling Object Instantiated Object Passed In Global Object