forked from junit-team/junit5
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue: junit-team#3708 add ParameterizedTest#argumentCountValidation
This allows parameterized tests to fail when there are more arguments provided than declared by the test method. This is done in a backwards compatible way by only enabling that validation when the new `junit.jupiter.params.argumentCountValidation` is set to `strict` or `ParameterizedTest#argumentCountValidation` is set to `ArgumentCountValidationMode.STRICT`.
- Loading branch information
1 parent
09659cf
commit 2e56d56
Showing
4 changed files
with
166 additions
and
0 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
junit-jupiter-params/src/main/java/org/junit/jupiter/params/ArgumentCountValidationMode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright 2015-2024 the original author or authors. | ||
* | ||
* All rights reserved. This program and the accompanying materials are | ||
* made available under the terms of the Eclipse Public License v2.0 which | ||
* accompanies this distribution and is available at | ||
* | ||
* https://www.eclipse.org/legal/epl-v20.html | ||
*/ | ||
|
||
package org.junit.jupiter.params; | ||
|
||
import org.apiguardian.api.API; | ||
import org.junit.jupiter.params.provider.ArgumentsSource; | ||
|
||
/** | ||
* Enumeration of argument count validation modes for {@link ParameterizedTest @ParameterizedTest}. | ||
* | ||
* <p>When an {@link ArgumentsSource} provides more arguments than declared by the test method, | ||
* there might be a bug in the test method or the {@link ArgumentsSource}. | ||
* By default, the additional arguments are ignored. | ||
* {@link ArgumentCountValidationMode} allows you to control how additional arguments are handled. | ||
* | ||
* @since 5.12 | ||
* @see ParameterizedTest | ||
*/ | ||
@API(status = API.Status.EXPERIMENTAL, since = "5.12") | ||
public enum ArgumentCountValidationMode { | ||
/** | ||
* Use the default cleanup mode. | ||
* | ||
* <p>The default cleanup mode may be changed via the | ||
* {@value ParameterizedTestExtension#ARGUMENT_COUNT_VALIDATION_KEY} configuration parameter | ||
* (see the User Guide for details on configuration parameters). | ||
*/ | ||
DEFAULT, | ||
|
||
/** | ||
* Use the "none" argument count validation mode. | ||
* | ||
* <p>When there are more arguments provided than declared by the test method, | ||
* these additional arguments are ignored. | ||
*/ | ||
NONE, | ||
|
||
/** | ||
* Use the strict argument count validation mode. | ||
* | ||
* <p>When there are more arguments provided than declared by the test method, this raises an error. | ||
*/ | ||
STRICT, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters