Mockito code generator

Compatible with IntelliJ IDEA
22.08.2015
3 316
The plugin generates boilerplate Mockito code that usually needs to be added manually to unit tests.

Auto-generated are:

  • RunWith(MockitoJUnitRunner.class) annotation for the class
  • Mocked fields for each non-static object declared in the test subject
  • Field for the test subject with @InjectMocks annotation
  • static imports for useful mockito functions like when, verify

To generate the Mockito code with the plugin hit ctrl shift M or use a choose the action from "Generate Action" context menu.

Download plugin

Recent change notes

  • Added generation of mocked fields for objects declared in a parent class of the tested class
  • Show error message when plugin used without Mockito or JUnit in the dependencies

General usage instructions

To generate the Mockito code with the plugin hit ctrl shift M or use a choose the action from "Generate Action" context menu.