In unit testing, "stubs", "mocks", and "fakes" are all dummy implementations of functions or objects that are used to test the behavior of another piece of code. However, they differ in the degree to which they are configured and the role they play in the testing process.
A "stub" is a very simple dummy implementation of a function or object that is used to return a predetermined value or simulate a specific condition. Stubs are often used to provide input values for the code under test or to test error handling.
A "mock" is a more sophisticated dummy implementation that can be configured to verify that certain conditions are met during the test. Mocks can be set up to verify that certain functions are called, certain values are returned, or certain conditions are met.
A "fake" is a working implementation of a function or object that is used in place of the real implementation for testing purposes. Fakes are often used when the real implementation is too complex or time-consuming to set up for a test, or when the real implementation has external dependencies that are difficult to manage in a test environment.
In general, stubs are the most basic form of dummy implementation and are used to provide input values or simulate simple conditions. Mocks are more advanced and are used to verify the behavior of the code under test. Fakes are fully functional implementations that are used to substitute for the real implementation in tests.
标签:real,dummy,used,implementation,certain,stub,between,test,mock From: https://www.cnblogs.com/chucklu/p/17036357.html