@@ -77,7 +77,7 @@ void constructorParameter() {
77
77
78
78
@ Test
79
79
void constructorParameterForNestedTestClass () {
80
- assertOneTestSucceeded (NestedConstructorParameterTestCase .class );
80
+ assertTestsSucceeded (NestedConstructorParameterTestCase .class , 2 );
81
81
}
82
82
83
83
@ Test
@@ -210,10 +210,11 @@ void afterEach(Long number, TestInfo testInfo, @MagicParameter("method") String
210
210
@ ExtendWith (LongParameterResolver .class )
211
211
class NestedConstructorParameterTestCase {
212
212
213
- NestedConstructorParameterTestCase (@ MagicParameter ("constructor" ) String text ) {
214
- // Index is 1 instead of 0, since constructors for non-static nested classes
213
+ NestedConstructorParameterTestCase (TestInfo testInfo , @ MagicParameter ("constructor" ) String text ) {
214
+ assertThat (testInfo ).isNotNull ();
215
+ // Index is 2 instead of 1, since constructors for non-static nested classes
215
216
// receive a reference to the enclosing instance as the first argument: this$0
216
- assertThat (text ).isEqualTo ("NestedConstructorParameterTestCase-1 -constructor" );
217
+ assertThat (text ).isEqualTo ("NestedConstructorParameterTestCase-2 -constructor" );
217
218
}
218
219
219
220
@ BeforeEach
@@ -239,6 +240,40 @@ void afterEach(Long number, TestInfo testInfo, @MagicParameter("method") String
239
240
assertThat (text ).isEqualTo ("afterEach-2-method" );
240
241
}
241
242
243
+ @ Nested
244
+ class DoublyNestedConstructorParameterTestCase {
245
+
246
+ DoublyNestedConstructorParameterTestCase (TestInfo testInfo , String text ) {
247
+ assertThat (testInfo ).isNotNull ();
248
+ // Index is 2 instead of 1, since constructors for non-static nested classes
249
+ // receive a reference to the enclosing instance as the first argument: this$0
250
+ assertThat (text ).isEqualTo ("DoublyNestedConstructorParameterTestCase-2-enigma" );
251
+ }
252
+
253
+ @ BeforeEach
254
+ void beforeEach (String text , TestInfo testInfo ) {
255
+ assertThat (text ).isEqualTo ("beforeEach-0-enigma" );
256
+ assertThat (testInfo ).isNotNull ();
257
+ }
258
+
259
+ @ Test
260
+ void test (TestInfo testInfo , String text ) {
261
+ assertThat (testInfo ).isNotNull ();
262
+ assertThat (text ).isEqualTo ("test-1-enigma" );
263
+ }
264
+
265
+ /**
266
+ * Redeclaring {@code @MagicParameter} should not result in a
267
+ * {@link ParameterResolutionException}.
268
+ */
269
+ @ AfterEach
270
+ void afterEach (Long number , TestInfo testInfo , @ MagicParameter ("method" ) String text ) {
271
+ assertThat (number ).isEqualTo (42L );
272
+ assertThat (testInfo ).isNotNull ();
273
+ assertThat (text ).isEqualTo ("afterEach-2-method" );
274
+ }
275
+ }
276
+
242
277
}
243
278
244
279
/**
0 commit comments