About
Mocking is just replacing or wrapping a function by another function at runtime called a mocking function.
Example:
var request = new HttpRequest(); // the real request
var mockRequest = new HttpMock(request); // the request is wrapped
This function overrule the actual implementation of a function during a test.
It permits then to:
- control the passed parameters
- return a known value or behavior.
Mock function are generally used to simulate a integration test with third party services such as:
- a database
- a http fetch (for rest API and other http services)
- a remote server
Articles Related
Framework
Java:
- mockito
Javascript: