Skip to content

Instantly share code, notes, and snippets.

Created September 8, 2018 23:29
What would you like to do?
public class TestMockitoInjection {
private BoringService service;
public TestMockitoInjection(@Mock BoringService service) {
this.service = service;
public void testConstructorInjectedValue() {
assertEquals(2, service.returnNumber());
public void testMethodInjection(@Mock BoringService service) {
assertEquals(3, service.returnNumber());
public class BoringService {
public int returnNumber() {
return 1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment