1 /* 2 * Copyright (c) 2017 Mockito contributors 3 * This program is made available under the terms of the MIT License. 4 */ 5 package org.mockitousage.junitrule; 6 7 import org.junit.Rule; 8 import org.junit.Test; 9 import org.mockito.InjectMocks; 10 import org.mockito.Mock; 11 import org.mockito.junit.MockitoJUnit; 12 import org.mockito.junit.MockitoRule; 13 14 import static org.junit.Assert.assertNotNull; 15 16 public class InvalidTargetMockitoJUnitRuleTest { 17 18 @Rule 19 public MockitoRule mockitoJUnitRule = MockitoJUnit.rule(); 20 21 @Mock 22 private Injected injected; 23 24 @InjectMocks 25 private InjectInto injectInto; 26 27 @Test shouldInjectWithInvalidReference()28 public void shouldInjectWithInvalidReference() throws Exception { 29 assertNotNull("Mock created", injected); 30 assertNotNull("Test object created", injectInto); 31 } 32 33 public static class Injected { } 34 35 public static class InjectInto { 36 private Injected injected; 37 getInjected()38 public Injected getInjected() { 39 return injected; 40 } 41 } 42 } 43