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:

Framework

Java:

Javascript: