Skip to content

Commit 6527613

Browse files
authored
Rename requireArguments to allowZeroInvocations (#4149)
1 parent 945e4b9 commit 6527613

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

documentation/src/docs/asciidoc/release-notes/release-notes-5.12.0-M1.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ JUnit repository on GitHub.
8585
* Extensions based on `TestTemplateInvocationContextProvider` can now allow returning zero
8686
invocation contexts by overriding the new `mayReturnZeroTestTemplateInvocationContexts`
8787
method.
88-
* The new `@ParameterizedTest(requireArguments = false)` attribute allows to specify that
88+
* The new `@ParameterizedTest(allowZeroInvocations = true)` attribute allows to specify that
8989
the absence of arguments is expected in some cases and should not cause a test failure.
9090
* Allow determining "shared resources" at runtime via the new `@ResourceLock#providers`
9191
attribute that accepts implementations of `ResourceLocksProvider`.

junit-jupiter-params/src/main/java/org/junit/jupiter/params/ParameterizedTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,18 +293,18 @@
293293
boolean autoCloseArguments() default true;
294294

295295
/**
296-
* Configure whether at least one set of arguments is required for this
296+
* Configure whether zero invocations are allowed for this
297297
* parameterized test.
298298
*
299-
* <p>Set this attribute to {@code false} if the absence of arguments is
299+
* <p>Set this attribute to {@code true} if the absence of arguments is
300300
* expected in some cases and should not cause a test failure.
301301
*
302-
* <p>Defaults to {@code true}.
302+
* <p>Defaults to {@code false}.
303303
*
304304
* @since 5.12
305305
*/
306306
@API(status = EXPERIMENTAL, since = "5.12")
307-
boolean requireArguments() default true;
307+
boolean allowZeroInvocations() default false;
308308

309309
/**
310310
* Configure how the number of arguments provided by an {@link ArgumentsSource} are validated.

junit-jupiter-params/src/main/java/org/junit/jupiter/params/ParameterizedTestExtension.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,15 @@ public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContex
8686
return createInvocationContext(formatter, methodContext, arguments, invocationCount.intValue());
8787
})
8888
.onClose(() ->
89-
Preconditions.condition(invocationCount.get() > 0 || !methodContext.annotation.requireArguments(),
89+
Preconditions.condition(invocationCount.get() > 0 || methodContext.annotation.allowZeroInvocations(),
9090
"Configuration error: You must configure at least one set of arguments for this @ParameterizedTest"));
9191
// @formatter:on
9292
}
9393

9494
@Override
9595
public boolean mayReturnZeroTestTemplateInvocationContexts(ExtensionContext extensionContext) {
9696
ParameterizedTestMethodContext methodContext = getMethodContext(extensionContext);
97-
return !methodContext.annotation.requireArguments();
97+
return methodContext.annotation.allowZeroInvocations();
9898
}
9999

100100
private ParameterizedTestMethodContext getMethodContext(ExtensionContext extensionContext) {

jupiter-tests/src/test/java/org/junit/jupiter/params/ParameterizedTestExtensionTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ void method() {
325325

326326
static class TestCaseAllowNoArgumentsMethod {
327327

328-
@ParameterizedTest(requireArguments = false)
328+
@ParameterizedTest(allowZeroInvocations = true)
329329
void method() {
330330
}
331331
}

jupiter-tests/src/test/java/org/junit/jupiter/params/ParameterizedTestIntegrationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2422,7 +2422,7 @@ void testThatRequiresArguments(String argument) {
24222422
fail("This test should not be executed, because no arguments are provided.");
24232423
}
24242424

2425-
@ParameterizedTest(requireArguments = false)
2425+
@ParameterizedTest(allowZeroInvocations = true)
24262426
@MethodSource("zeroArgumentsProvider")
24272427
void testThatDoesNotRequireArguments(String argument) {
24282428
fail("This test should not be executed, because no arguments are provided.");

0 commit comments

Comments
 (0)