I have a simple Java method, I would like to check that it does not throw any exceptions.
I have already mocked the parameters etc, however I am not sure how to use Mockito to test that no exception has been thrown from the method?
Current test code:
@Test public void testGetBalanceForPerson() { //creating mock person Person person1 = mock(Person.class); when(person1.getId()).thenReturn("mockedId"); //calling method under test myClass.getBalanceForPerson(person1); //How to check that an exception isn't thrown? }
getBalanceForPersonreturns the expected value - but that's a JUnit check,assertEquals(expectedBalance, result).