Question

In his talk, Ian Cooper (at 33:30), mentioned the imposter design pattern. Searching the net, I found that it is introduced in the Test Driven Development : by example, but I couldn't find any more details.

  • what exactly is the imposter design pattern?
  • how to implement it in c++?
Was it helpful?

Solution

Imposter is also known as Test Double.

When we are writing a test in which we cannot (or choose not to) use a real depended-on component (DOC), we can replace it with a Test Double. The Test Double doesn’t have to behave exactly like the real DOC; it merely has to provide the same API as the real DOC so that the SUT thinks it is the real one!

Implementation depends on the variation:

Sketch types of test doubles
(source: xunitpatterns.com)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top