40 likes | 169 Views
Provide a safety net for refactoring Think about each component from a client’s point of view Testable code is loosely coupled code is good code!. What is TDD Good For?. For any project of non-trivial size How to demonstrate this in a short talk?. Thank You Leon Bambrick.
E N D
Provide a safety net for refactoring • Think about each component from a client’s point of view • Testable code is loosely coupled code is good code! What is TDD Good For? For any project of non-trivial size How to demonstrate this in a short talk?
Thank You Leon Bambrick So Let’s Validate an Email Address! • Should match email@domain • Should match domains in India @abc.co.in • Should not match if domain has illegal chars • Etc.
Lets Expand A Bit Add a User • Must have a name • Must have valid email • Once we know this is true we can save But Unit Tests should test a unit, not a system! We need to be able to test each component in isolation We need a mock UserValidator with canned responses
Enter Mocking • Rhino Mocks • MOQ • Typemock Isolator • Provide canned responses to method calls • Establish expectations and verify them • Assert that methods were called por not called