Created
March 9, 2020 16:40
-
-
Save flaudanum/6426beb18ca0cf0e6b36a9cc2c89fb2c to your computer and use it in GitHub Desktop.
Mockito: mock a void method to do nothing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| BackendRunner mockedRunner = mock(BackendRunner.class); | |
| // Mock method runProcess() to do nothing | |
| doAnswer(new Answer<Void>() { | |
| public Void answer(InvocationOnMock invocation) { | |
| Object[] args = invocation.getArguments(); | |
| System.out.println("called with arguments: " + Arrays.toString(args)); | |
| return null; | |
| } | |
| }).when(mockedRunner).runProcess(any()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment