-
Sources
-
Understand Stub, Mock and Fake in Unit Testing
- https://www.c-sharpcorner.com/UploadFile/dacca2/understand-stub-mock-and-fake-in-unit-testing/
-
Test Doubles — Fakes, Mocks and Stubs.
- https://www.c-sharpcorner.com/UploadFile/dacca2/understand-stub-mock-and-fake-in-unit-testing/
-
Test Double
- http://xunitpatterns.com/Test%20Double.html
-
Martin Fowler: Mocks Aren't Stubs
- https://martinfowler.com/articles/mocksArentStubs.html
-
DIFFERENCE BETWEEN FAKING, MOCKING, AND STUBBING
- http://www.rubencanton.com/blog/2015/03/difference-between-faking-mocking-and-stubbing.html
-
What's the difference between faking, mocking, and stubbing?
- https://stackoverflow.com/questions/346372/whats-the-difference-between-faking-mocking-and-stubbing
-
Mock
-
unit test
- A mock object is a fake object in the system that decides whether the unit test has passed or failed
- Mocks are objects that register calls they receive.
- objects pre-programmed with expectations which form a specification of the calls they are expected to receive
- an object on which you set expectations
- a class that implements an interface and allows the ability to dynamically set the values to return/exceptions to throw from particular methods and provides the ability to check if particular methods have been called/not called
-
Stub
-
unit test
- A stub can replace an object in the unit testing world
- Stub is an object that holds predefined data and uses it to answer calls during tests
- provide canned answers to calls made during the test, usually not responding at all to anything outside what's programmed in for the test
- an object that provides predefined answers to method calls
- like a mock class, except that it doesn't provide the ability to verify that methods have been called/not called
-
Fake
-
unit test
- fake is, not real
- fakes are objects that have working implementations, but not same as production one
- objects actually have working implementations, but usually take some shortcut which makes them not suitable for production
- an object with limited capabilities
- a class that implements an interface but contains fixed data and no logic