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