mock a void method junit java code example Example: java doreturn void doNothing().when(yourMock).yourMockedMethod();