What is Mocking?

The process of replacing a module with generic and mostly empty object, called a mock.

Advantages:

  • Isolates our code from its dependencies.
  • Write tests with no knowledge of dependencies.
  • No need to change tests after change of dependencies.
  • Reduces false positives.
  • Tests will be less fragile.
  • Easier for other developers to understand.