Questions and answers
- Are the terms stub and mock used interchangeably?
Yes, even though they have different meanings. In normal conversation, we tend to trade precision for fluency, and that’s okay. It’s important to understand the different uses that each kind of test double has. When speaking, it’s usually better to not be pedantic whenever a group of people knows what is meant. So long as we stay aware that a test double is the proper general term and that the specific types of doubles have different roles, all will be well.
- What is the problem known as “testing the mock”?
This happens when the SUT has no real logic in it, yet we try to write a unit test anyway. We wire up a test double to the SUT and write the test. What we will find is that the assertions only check that the test double-returned the right data. It’s an indication that we have tested at the wrong level. This kind of error can be driven by setting...