Mockito

Mocking framework for Java unit tests.

Execution & architecture flow

  1. Create mock
  2. Stub: when(...).thenReturn
  3. Run code under test
  4. verify() calls

Engineering capabilities

  • Stubbing return values and exceptions
  • Verifying interactions and invocation order
  • Argument matchers and captors
  • Spies for partial mocking

Where used

  • Java testing at Oracle

Official documentation