From the course: Test-Driven Development in C++

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Test doubles overview

Test doubles overview

- [Instructor] In this lecture, I'm going to go over how you can make sure you're running your unit tests in isolation, using the concepts of dummies, fakes, stubs, spies, and mocks. So what are test doubles? Almost all code that gets implemented will depend on another piece of code in the system. Those other pieces of code are oftentimes trying to do things or communicate with things that are not available in a unit testing environment or are so slow that they would make our unit tests extremely slow. Test doubles are the answer to that problem. They're objects created in the tests to replace the real production system collaborators. There are many types of test doubles. Dummy objects are the simplest. They are simply placeholders that are intended to be passed around but not actually called or used in any real way. They will often generate exceptions if they are called. Fake objects have a different and usually simplified implementation from the production collaborator that makes…

Contents