1 package org.mockitousage.junitrule; 2 3 import org.junit.Rule; 4 import org.junit.Test; 5 import org.mockito.InjectMocks; 6 import org.mockito.Mock; 7 import org.mockito.junit.MockitoJUnit; 8 import org.mockito.junit.MockitoRule; 9 10 import static org.junit.Assert.assertNotNull; 11 12 public class InvalidTargetMockitoJUnitRuleTest { 13 14 @Rule 15 public MockitoRule mockitoJUnitRule = MockitoJUnit.rule(); 16 17 @Mock 18 private Injected injected; 19 20 @InjectMocks 21 private InjectInto injectInto; 22 23 @Test 24 public void shouldInjectWithInvalidReference() throws Exception { 25 assertNotNull("Mock created", injected); 26 assertNotNull("Test object created", injectInto); 27 } 28 29 public static class Injected { } 30 31 public static class InjectInto { 32 private Injected injected; 33 34 public Injected getInjected() { 35 return injected; 36 } 37 } 38 } 39