Annotation Type FixtureParameter
-
@Retention(RUNTIME) @Target(PARAMETER) public @interface FixtureParameter
This annotation has to be added to each fixture parameter.- Author:
- Rene Schneider - initial API and implementation
-
-
Required Element Summary
Required Elements Modifier and Type Required Element Description java.lang.String
name
The name of the parameter.
-
-
-
-
mandatory
boolean mandatory
Whether the parameter must be provided or is optional. By default parameters are optional (= non-mandatory, so mandatory = false).Note that there is a significant difference between making a parameter mandatory and allowing or disallowing the null value - just because a parameter is mandatory it may still be null, because by providing a null value explicitly in the test script, the "mandatory" part is satisfied. Please see
nullable()
as well if you also want to ensure a parameter may never be null.If an optional parameter is not provided in the test script, the method will be called with "null" for the specific parameter. Since primitive types cannot be null, using a primitive type for a method parameter automatically makes the parameter mandatory (even if you set mandatory=false in this annotation, it will be ignored in that case).
- Returns:
- Default:
- false
-
-
-
nullable
boolean nullable
Whether a parameter may be the value "null" at the time the fixture method is invoked. By default, parameters are nullable. If a fixture parameter is marked as non-nullable, a null value will lead to anIllegalArgumentException
at runtime, and directly providing null values within test scripts will lead to errors at compile time.In case of multiple parameter values (= an array is provided to the fixture), setting the parameter to non-nullable will cause an exception if at least one of the provided values is null, regardless of whether other provided values are non-null.
Note that there is a significant difference between allowing or disallowing null as a value vs. making a parameter mandatory! Please see
mandatory()
as well.If the type used for a parameter is a primitive type which cannot be null, the respective parameter is automatically non-nullable, regardless of this setting.
- Returns:
- Default:
- true
-
-