Faking Dependencies

Following on from the learning hours on Stubs. Fakes are like stubs but with a real implementation.

Connect

Mark the true statements and not the other ones:

Concept - Fakes

Fakes are like stubs but they actually have a real implementation. Stubs just return hard-coded answers but Fakes do calculations, have state, and behave appropriately. Typical abstractions that you fake are files, queues, iterators, data stores.

Concrete

Html Converter. First get them to read the code and establish which abstraction you want to replace with a test double. Make sure they have the documentation for the in-memory string version of a file for their programming language.

Get them to find the documentation for their language if you don’t have it.

Remind them to preserve the original constructor in addition to a new one that lets you inject the test double.

Conclusions

When should you use a Test Double? In particular, when should you use a Fake? Make some notes and share with the group.