Monday 3:40 p.m.–4:25 p.m.
Intro to Mocking: Why Unit Testing Doesn't Have To Be So Hard
Daniel Davis
Audience level:
- Novice
Description
Are you frustrated when writing unit tests? Do you feel guilty for not writing more? Many developers know they should be writing more unit tests, but are missing one key ingredient: mocking makes writing unit tests so much easier! In this talk, I'll introduce 3 common scenarios that are notoriously difficult to unit test and show how mocking can be used to write simple, effective tests.
Abstract
Many developers want to write better code, but simply don't know how to write units tests for:
- Code that calls other code (i.e. code with dependencies)
- Methods that have no return value
- Code that throws exceptions
Mocking provides a valuable tool for solving these problems. In this talk, we'll discuss the scenarios in which Mocking is useful, the strategies for addressing each of the cases above and write simple, clean unit tests using the built-in Mock library.