Skip to content

Instantly share code, notes, and snippets.

@frekele
Created December 1, 2020 07:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frekele/cbb9c1e6daf9507a5d449d1c32908a8c to your computer and use it in GitHub Desktop.
Save frekele/cbb9c1e6daf9507a5d449d1c32908a8c to your computer and use it in GitHub Desktop.
public class MockitoTest {
@Mock
MyDatabase databaseMock;
@Rule public MockitoRule mockitoRule = MockitoJUnit.rule();
@Test
public void testQuery() {
ClassToTest t = new ClassToTest(databaseMock);
boolean check = t.query("* from t");
assertTrue(check);
verify(databaseMock).query("* from t");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment