Search⌘ K

Interactions

Explore how to manage side effects in software testing by using test doubles and mock objects. Understand how to isolate code behavior, verify method interactions, and apply these techniques in languages like Ruby and C to improve your testing discipline.

We'll cover the following...

Now, what about those side effects? It’s a huge pain to augment our code with constructs like “If in test mode, don’t actually connect to the database." Instead, most languages have a mechanism for creating test doubles that take the place of the resource our function wants to use.

Test double

In test double, the code undergoing the test is isolated from the rest of the code, and all facets of its behavior are tested.

Let’s rewrite the ...