1 package mockit;
2
3 import javax.inject.Inject;
4
5 import org.junit.Before;
6 import org.junit.Rule;
7 import org.junit.Test;
8 import org.junit.rules.ExpectedException;
9
10
11
12
13 public final class TestedFieldWithFailedFullDITest {
14
15
16 @Rule
17 public final ExpectedException thrown = ExpectedException.none();
18
19
20
21
22 @Before
23 public void configureExpectedException() {
24 thrown.expect(IllegalStateException.class);
25 thrown.expectMessage("Missing @Tested or @Injectable");
26 thrown.expectMessage("for parameter \"value\" in constructor ClassWithParameterizedConstructor(int value)");
27 thrown.expectMessage("when initializing field ");
28 thrown.expectMessage("dependency");
29 thrown.expectMessage("of @Tested object \""
30 + ClassWithFieldOfClassHavingParameterizedConstructor.class.getSimpleName() + " tested");
31 }
32
33
34
35
36 static class ClassWithFieldOfClassHavingParameterizedConstructor {
37
38 @Inject
39 ClassWithParameterizedConstructor dependency;
40 }
41
42
43
44
45 static class ClassWithParameterizedConstructor {
46
47
48
49
50
51
52 ClassWithParameterizedConstructor(@SuppressWarnings("unused") int value) {
53 }
54 }
55
56
57 @Tested(fullyInitialized = true)
58 ClassWithFieldOfClassHavingParameterizedConstructor tested;
59
60
61
62
63 @Test
64 public void attemptToUseTestedObjectWhoseCreationFailedDueToInjectableWithNullValue() {
65 }
66
67
68
69
70 @Test
71 public void attemptToUseTestedObjectWhoseCreationFailedDueToInjectableWithNullValue2() {
72 }
73 }