1919import org .springframework .test .context .TestContextManager ;
2020import org .springframework .test .context .TestExecutionListener ;
2121
22+ import static io .cucumber .spring .TestContextAdaptor .create ;
2223import static java .util .Collections .singletonList ;
2324import static org .junit .jupiter .api .Assertions .assertAll ;
2425import static org .junit .jupiter .api .Assertions .assertDoesNotThrow ;
@@ -44,7 +45,7 @@ void verifyNoMoroInteractions() {
4445 @ Test
4546 void invokesAllLiveCycleHooks () throws Exception {
4647 TestContextManager manager = new TestContextManager (SomeContextConfiguration .class );
47- TestContextAdaptor adaptor = new TestContextAdaptor ( manager , singletonList (SomeContextConfiguration .class ));
48+ TestContextAdaptor adaptor = create (() -> manager , singletonList (SomeContextConfiguration .class ));
4849 manager .registerTestExecutionListeners (listener );
4950 InOrder inOrder = inOrder (listener );
5051
@@ -63,7 +64,7 @@ void invokesAllLiveCycleHooks() throws Exception {
6364 @ Test
6465 void invokesAfterClassIfBeforeClassFailed () throws Exception {
6566 TestContextManager manager = new TestContextManager (SomeContextConfiguration .class );
66- TestContextAdaptor adaptor = new TestContextAdaptor ( manager , singletonList (SomeContextConfiguration .class ));
67+ TestContextAdaptor adaptor = create (() -> manager , singletonList (SomeContextConfiguration .class ));
6768 manager .registerTestExecutionListeners (listener );
6869 InOrder inOrder = inOrder (listener );
6970
@@ -79,7 +80,7 @@ void invokesAfterClassIfBeforeClassFailed() throws Exception {
7980 @ Test
8081 void invokesAfterClassIfPrepareTestInstanceFailed () throws Exception {
8182 TestContextManager manager = new TestContextManager (SomeContextConfiguration .class );
82- TestContextAdaptor adaptor = new TestContextAdaptor ( manager , singletonList (SomeContextConfiguration .class ));
83+ TestContextAdaptor adaptor = create (() -> manager , singletonList (SomeContextConfiguration .class ));
8384 manager .registerTestExecutionListeners (listener );
8485 InOrder inOrder = inOrder (listener );
8586
@@ -95,7 +96,7 @@ void invokesAfterClassIfPrepareTestInstanceFailed() throws Exception {
9596 @ Test
9697 void invokesAfterMethodIfBeforeMethodThrows () throws Exception {
9798 TestContextManager manager = new TestContextManager (SomeContextConfiguration .class );
98- TestContextAdaptor adaptor = new TestContextAdaptor ( manager , singletonList (SomeContextConfiguration .class ));
99+ TestContextAdaptor adaptor = create (() -> manager , singletonList (SomeContextConfiguration .class ));
99100 manager .registerTestExecutionListeners (listener );
100101 InOrder inOrder = inOrder (listener );
101102
@@ -114,7 +115,7 @@ void invokesAfterMethodIfBeforeMethodThrows() throws Exception {
114115 @ Test
115116 void invokesAfterTestExecutionIfBeforeTestExecutionThrows () throws Exception {
116117 TestContextManager manager = new TestContextManager (SomeContextConfiguration .class );
117- TestContextAdaptor adaptor = new TestContextAdaptor ( manager , singletonList (SomeContextConfiguration .class ));
118+ TestContextAdaptor adaptor = create (() -> manager , singletonList (SomeContextConfiguration .class ));
118119 manager .registerTestExecutionListeners (listener );
119120 InOrder inOrder = inOrder (listener );
120121
@@ -134,7 +135,7 @@ void invokesAfterTestExecutionIfBeforeTestExecutionThrows() throws Exception {
134135 @ Test
135136 void invokesAfterTestMethodIfAfterTestExecutionThrows () throws Exception {
136137 TestContextManager manager = new TestContextManager (SomeContextConfiguration .class );
137- TestContextAdaptor adaptor = new TestContextAdaptor ( manager , singletonList (SomeContextConfiguration .class ));
138+ TestContextAdaptor adaptor = create (() -> manager , singletonList (SomeContextConfiguration .class ));
138139 manager .registerTestExecutionListeners (listener );
139140 InOrder inOrder = inOrder (listener );
140141
@@ -155,7 +156,7 @@ void invokesAfterTestMethodIfAfterTestExecutionThrows() throws Exception {
155156 @ Test
156157 void invokesAfterTesClassIfAfterTestMethodThrows () throws Exception {
157158 TestContextManager manager = new TestContextManager (SomeContextConfiguration .class );
158- TestContextAdaptor adaptor = new TestContextAdaptor ( manager , singletonList (SomeContextConfiguration .class ));
159+ TestContextAdaptor adaptor = create (() -> manager , singletonList (SomeContextConfiguration .class ));
159160 manager .registerTestExecutionListeners (listener );
160161 InOrder inOrder = inOrder (listener );
161162
@@ -176,7 +177,7 @@ void invokesAfterTesClassIfAfterTestMethodThrows() throws Exception {
176177 @ Test
177178 void invokesAllMethodsPriorIfAfterTestClassThrows () throws Exception {
178179 TestContextManager manager = new TestContextManager (SomeContextConfiguration .class );
179- TestContextAdaptor adaptor = new TestContextAdaptor ( manager , singletonList (SomeContextConfiguration .class ));
180+ TestContextAdaptor adaptor = create (() -> manager , singletonList (SomeContextConfiguration .class ));
180181 manager .registerTestExecutionListeners (listener );
181182 InOrder inOrder = inOrder (listener );
182183
@@ -198,7 +199,7 @@ void invokesAllMethodsPriorIfAfterTestClassThrows() throws Exception {
198199 @ ValueSource (classes = { WithAutowiredDependency .class , WithConstructorDependency .class })
199200 void autowireAndPostProcessesOnlyOnce (Class <? extends Spy > testClass ) {
200201 TestContextManager manager = new TestContextManager (testClass );
201- TestContextAdaptor adaptor = new TestContextAdaptor ( manager , singletonList (testClass ));
202+ TestContextAdaptor adaptor = create (() -> manager , singletonList (testClass ));
202203
203204 assertAll (
204205 () -> assertDoesNotThrow (adaptor ::start ),
0 commit comments