Module org.junit.jupiter.params
Interface ArgumentsAccessor
- All Known Implementing Classes:
DefaultArgumentsAccessor
ArgumentsAccessor
defines the public API for accessing arguments provided
by an ArgumentsProvider
for a single invocation of a
@ParameterizedTest
method.
Specifically, an ArgumentsAccessor
aggregates a set of
arguments for a given invocation of a parameterized test and provides convenience
methods for accessing those arguments in a type-safe manner with support for
automatic type conversion.
An instance of ArgumentsAccessor
will be automatically supplied
for any parameter of type ArgumentsAccessor
in a parameterized test.
In addition, ArgumentsAggregator
implementations are given access to
an ArgumentsAccessor
.
This interface is not intended to be implemented by clients.
Additional Kotlin arguments accessors can be
found as extension functions in the org.junit.jupiter.params.aggregator
package.
- Since:
- 5.2
- See Also:
ArgumentsAggregator
,ParameterizedTest
-
Method Summary
Modifier and TypeMethodDescriptionget(int index)
Get the value of the argument at the given index as anObject
.<T> T
Get the value of the argument at the given index as an instance of the required type.getBoolean(int index)
Get the value of the argument at the given index as aBoolean
, performing automatic type conversion as necessary.getByte(int index)
Get the value of the argument at the given index as aByte
, performing automatic type conversion as necessary.getCharacter(int index)
Get the value of the argument at the given index as aCharacter
, performing automatic type conversion as necessary.getDouble(int index)
Get the value of the argument at the given index as aDouble
, performing automatic type conversion as necessary.getFloat(int index)
Get the value of the argument at the given index as aFloat
, performing automatic type conversion as necessary.getInteger(int index)
Get the value of the argument at the given index as aInteger
, performing automatic type conversion as necessary.getLong(int index)
Get the value of the argument at the given index as aLong
, performing automatic type conversion as necessary.getShort(int index)
Get the value of the argument at the given index as aShort
, performing automatic type conversion as necessary.getString(int index)
Get the value of the argument at the given index as aString
, performing automatic type conversion as necessary.int
size()
Get the number of arguments in this accessor.Object[]
toArray()
Get all arguments in this accessor as an array.toList()
Get all arguments in this accessor as an immutable list.
-
Method Details
-
get
Get the value of the argument at the given index as anObject
.- Parameters:
index
- the index of the argument to get; must be greater than or equal to zero and less thansize()
- Returns:
- the value at the given index, potentially
null
- Throws:
ArgumentAccessException
-
get
Get the value of the argument at the given index as an instance of the required type.- Parameters:
index
- the index of the argument to get; must be greater than or equal to zero and less thansize()
requiredType
- the required type of the value; nevernull
- Returns:
- the value at the given index, potentially
null
- Throws:
ArgumentAccessException
-
getCharacter
Get the value of the argument at the given index as aCharacter
, performing automatic type conversion as necessary.- Parameters:
index
- the index of the argument to get; must be greater than or equal to zero and less thansize()
- Returns:
- the value at the given index, potentially
null
- Throws:
ArgumentAccessException
- if the value cannot be accessed or converted to the desired type
-
getBoolean
Get the value of the argument at the given index as aBoolean
, performing automatic type conversion as necessary.- Parameters:
index
- the index of the argument to get; must be greater than or equal to zero and less thansize()
- Returns:
- the value at the given index, potentially
null
- Throws:
ArgumentAccessException
- if the value cannot be accessed or converted to the desired type
-
getByte
Get the value of the argument at the given index as aByte
, performing automatic type conversion as necessary.- Parameters:
index
- the index of the argument to get; must be greater than or equal to zero and less thansize()
- Returns:
- the value at the given index, potentially
null
- Throws:
ArgumentAccessException
- if the value cannot be accessed or converted to the desired type
-
getShort
Get the value of the argument at the given index as aShort
, performing automatic type conversion as necessary.- Parameters:
index
- the index of the argument to get; must be greater than or equal to zero and less thansize()
- Returns:
- the value at the given index, potentially
null
- Throws:
ArgumentAccessException
- if the value cannot be accessed or converted to the desired type
-
getInteger
Get the value of the argument at the given index as aInteger
, performing automatic type conversion as necessary.- Parameters:
index
- the index of the argument to get; must be greater than or equal to zero and less thansize()
- Returns:
- the value at the given index, potentially
null
- Throws:
ArgumentAccessException
- if the value cannot be accessed or converted to the desired type
-
getLong
Get the value of the argument at the given index as aLong
, performing automatic type conversion as necessary.- Parameters:
index
- the index of the argument to get; must be greater than or equal to zero and less thansize()
- Returns:
- the value at the given index, potentially
null
- Throws:
ArgumentAccessException
- if the value cannot be accessed or converted to the desired type
-
getFloat
Get the value of the argument at the given index as aFloat
, performing automatic type conversion as necessary.- Parameters:
index
- the index of the argument to get; must be greater than or equal to zero and less thansize()
- Returns:
- the value at the given index, potentially
null
- Throws:
ArgumentAccessException
- if the value cannot be accessed or converted to the desired type
-
getDouble
Get the value of the argument at the given index as aDouble
, performing automatic type conversion as necessary.- Parameters:
index
- the index of the argument to get; must be greater than or equal to zero and less thansize()
- Returns:
- the value at the given index, potentially
null
- Throws:
ArgumentAccessException
- if the value cannot be accessed or converted to the desired type
-
getString
Get the value of the argument at the given index as aString
, performing automatic type conversion as necessary.- Parameters:
index
- the index of the argument to get; must be greater than or equal to zero and less thansize()
- Returns:
- the value at the given index, potentially
null
- Throws:
ArgumentAccessException
- if the value cannot be accessed or converted to the desired type
-
size
int size()Get the number of arguments in this accessor. -
toArray
Object[] toArray()Get all arguments in this accessor as an array. -
toList
Get all arguments in this accessor as an immutable list.
-