Stub vs Mock

Purpose When developing, you may encounter the following concerns: Why are my tests breaking like this? Is this correct? Mocking this is so hard…! Why are there so many predefined states? How do I manage them? A good example to explain this is understanding the difference between stubs and mocks. This post explains that difference. Why? It helps explain integration and unit testing more clearly. Source: https://martinfowler.com/articles/mocksArentStubs.html Key Terms Test Double A general term for objects that pretend to be real objects for testing purposes. Types of test doubles include Dummy, Fake, Spies, Stubs, and Mocks. The term comes from “stunt double” in movies—think of someone performing dangerous actions in place of the actor. ...

June 2, 2025