Skip to content

Instantly share code, notes, and snippets.

@caseyscarborough
Created June 14, 2015 18:10
Show Gist options
  • Save caseyscarborough/60028ca3cbc33cd78d52 to your computer and use it in GitHub Desktop.
Save caseyscarborough/60028ca3cbc33cd78d52 to your computer and use it in GitHub Desktop.
Mockito Example
public class DomainBlackListTest extends MockedTester {
@Mock public EventBus eb;
@Mock public EventBusSingleton eventBus;
@Before public void initMocks() {
when(eventBus.getEventBus())
.thenReturn(eb);
}
@Test public void simple() {
DomainBlackList d = new DomainBlackList(eventBus);
// .....
}
}
public class MockedTester {
public MockedTester() {
MockitoAnnotations.initMocks(this);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment