@@ -1117,35 +1117,52 @@ private EngineExecutionResults execute(String methodName, Class<?>... methodPara
11171117 class UnusedArgumentsWithStrictArgumentsCountIntegrationTests {
11181118 @ Test
11191119 void failsWithArgumentsSourceProvidingUnusedArguments () {
1120- var results = execute (UnusedArgumentsTestCase .class , "testWithTwoUnusedStringArgumentsProvider" ,
1120+ var results = execute (ArgumentCountValidationMode . STRICT , UnusedArgumentsTestCase .class , "testWithTwoUnusedStringArgumentsProvider" ,
11211121 String .class );
11221122 results .allEvents ().assertThatEvents () //
11231123 .haveExactly (1 , event (EventConditions .finishedWithFailure (message (
1124- "Configuration error: the @ParameterizedTest has 1 argument(s) but there were 2 argument(s) provided./ nNote: the provided arguments are [foo, unused1]" ))));
1124+ "Configuration error: the @ParameterizedTest has 1 argument(s) but there were 2 argument(s) provided.\ n Note: the provided arguments are [foo, unused1]" ))));
11251125 }
11261126
11271127 @ Test
11281128 void failsWithMethodSourceProvidingUnusedArguments () {
1129- var results = execute (UnusedArgumentsTestCase .class , "testWithMethodSourceProvidingUnusedArguments" ,
1129+ var results = execute (ArgumentCountValidationMode . STRICT , UnusedArgumentsTestCase .class , "testWithMethodSourceProvidingUnusedArguments" ,
11301130 String .class );
11311131 results .allEvents ().assertThatEvents () //
11321132 .haveExactly (1 , event (EventConditions .finishedWithFailure (message (
1133- "Configuration error: the @ParameterizedTest has 1 argument(s) but there were 2 argument(s) provided./nNote: the provided arguments are [foo, unused1]" ))));
1133+ "Configuration error: the @ParameterizedTest has 1 argument(s) but there were 2 argument(s) provided.\n Note: the provided arguments are [foo, unused1]" ))));
1134+ }
1135+
1136+ @ Test
1137+ void failsWithCsvSourceUnusedArgumentsAndStrictArgumentCountValidationAnnotationAttribute () {
1138+ var results = execute (ArgumentCountValidationMode .NONE , UnusedArgumentsTestCase .class , "testWithStrictArgumentCountValidation" ,
1139+ String .class );
1140+ results .allEvents ().assertThatEvents () //
1141+ .haveExactly (1 , event (EventConditions .finishedWithFailure (message (
1142+ "Configuration error: the @ParameterizedTest has 1 argument(s) but there were 2 argument(s) provided.\n Note: the provided arguments are [foo, unused1]" ))));
1143+ }
1144+
1145+ @ Test
1146+ void executesWithCsvSourceUnusedArgumentsAndArgumentCountValidationAnnotationAttribute () {
1147+ var results = execute (ArgumentCountValidationMode .NONE , UnusedArgumentsTestCase .class , "testWithNoneArgumentCountValidation" , String .class );
1148+ results .allEvents ().assertThatEvents () //
1149+ .haveExactly (1 , event (test (), displayName ("[1] argument=foo" ), finishedWithFailure (message ("foo" ))));
11341150 }
11351151
11361152 @ Test
11371153 void executesWithMethodSourceProvidingUnusedArguments () {
1138- var results = execute (RepeatableSourcesTestCase .class , "testWithRepeatableCsvSource" , String .class );
1154+ var results = execute (ArgumentCountValidationMode . STRICT , RepeatableSourcesTestCase .class , "testWithRepeatableCsvSource" , String .class );
11391155 results .allEvents ().assertThatEvents () //
11401156 .haveExactly (1 , event (test (), displayName ("[1] argument=a" ), finishedWithFailure (message ("a" )))) //
11411157 .haveExactly (1 , event (test (), displayName ("[2] argument=b" ), finishedWithFailure (message ("b" ))));
11421158 }
11431159
1144- private EngineExecutionResults execute (Class <?> javaClass , String methodName ,
1160+ private EngineExecutionResults execute (ArgumentCountValidationMode configurationValue , Class <?> javaClass , String methodName ,
11451161 Class <?>... methodParameterTypes ) {
1146- return EngineTestKit .engine (new JupiterTestEngine ()).selectors (
1147- selectMethod (javaClass , methodName , methodParameterTypes )).configurationParameter (
1148- ParameterizedTestExtension .ARGUMENT_COUNT_VALIDATION_KEY , "strict" ).execute ();
1162+ return EngineTestKit .engine (new JupiterTestEngine ()) //
1163+ .selectors (selectMethod (javaClass , methodName , methodParameterTypes )) //
1164+ .configurationParameter (ParameterizedTestExtension .ARGUMENT_COUNT_VALIDATION_KEY , configurationValue .name ().toLowerCase ()) //
1165+ .execute ();
11491166 }
11501167 }
11511168
@@ -2065,6 +2082,17 @@ void testWithFieldSourceProvidingUnusedArguments(String argument) {
20652082 static Supplier <Stream <Arguments >> unusedArgumentsProviderField = //
20662083 () -> Stream .of (arguments ("foo" , "unused1" ), arguments ("bar" , "unused2" ));
20672084
2085+ @ ParameterizedTest (argumentCountValidation = ArgumentCountValidationMode .STRICT )
2086+ @ CsvSource ({ "foo, unused1" })
2087+ void testWithStrictArgumentCountValidation (String argument ) {
2088+ fail (argument );
2089+ }
2090+
2091+ @ ParameterizedTest (argumentCountValidation = ArgumentCountValidationMode .NONE )
2092+ @ CsvSource ({ "foo, unused1" })
2093+ void testWithNoneArgumentCountValidation (String argument ) {
2094+ fail (argument );
2095+ }
20682096 }
20692097
20702098 static class LifecycleTestCase {
0 commit comments