Top Description Methods
org.junit.jupiter.params.aggregator

public Interface ArgumentsAccessor

Known Direct Implementers
org.junit.jupiter.params.aggregator.DefaultArgumentsAccessor
Annotations
@API
status:STABLE
since:5.7
Static Imports
org.apiguardian.api.API.Status.STABLE

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, org.junit.jupiter.params.ParameterizedTest

Method Summary

Modifier and TypeMethod and Description
public @Nullable Object

Returns:

the value at the given index, potentially null
get
(int
the index of the argument to get; must be greater than or equal to zero and less than size
index
)

Get the value of the argument at the given index as an Object.

public <T> @Nullable T

Returns:

the value at the given index, potentially null
get
(int
the index of the argument to get; must be greater than or equal to zero and less than size
index
,
Class<T>
the required type of the value; never null
requiredType
)

Get the value of the argument at the given index as an instance of the required type.

public @Nullable Boolean

Returns:

the value at the given index, potentially null
getBoolean
(int
the index of the argument to get; must be greater than or equal to zero and less than size
index
)

Get the value of the argument at the given index as a Boolean, performing automatic type conversion as necessary.

public @Nullable Byte

Returns:

the value at the given index, potentially null
getByte
(int
the index of the argument to get; must be greater than or equal to zero and less than size
index
)

Get the value of the argument at the given index as a Byte, performing automatic type conversion as necessary.

public @Nullable Character

Returns:

the value at the given index, potentially null
getCharacter
(int
the index of the argument to get; must be greater than or equal to zero and less than size
index
)

Get the value of the argument at the given index as a Character, performing automatic type conversion as necessary.

public @Nullable Double

Returns:

the value at the given index, potentially null
getDouble
(int
the index of the argument to get; must be greater than or equal to zero and less than size
index
)

Get the value of the argument at the given index as a Double, performing automatic type conversion as necessary.

public @Nullable Float

Returns:

the value at the given index, potentially null
getFloat
(int
the index of the argument to get; must be greater than or equal to zero and less than size
index
)

Get the value of the argument at the given index as a Float, performing automatic type conversion as necessary.

public @Nullable Integer

Returns:

the value at the given index, potentially null
getInteger
(int
the index of the argument to get; must be greater than or equal to zero and less than size
index
)

Get the value of the argument at the given index as a Integer, performing automatic type conversion as necessary.

public int
getInvocationIndex()

Get the index of the current test invocation.

public @Nullable Long

Returns:

the value at the given index, potentially null
getLong
(int
the index of the argument to get; must be greater than or equal to zero and less than size
index
)

Get the value of the argument at the given index as a Long, performing automatic type conversion as necessary.

public @Nullable Short

Returns:

the value at the given index, potentially null
getShort
(int
the index of the argument to get; must be greater than or equal to zero and less than size
index
)

Get the value of the argument at the given index as a Short, performing automatic type conversion as necessary.

public @Nullable String

Returns:

the value at the given index, potentially null
getString
(int
the index of the argument to get; must be greater than or equal to zero and less than size
index
)

Get the value of the argument at the given index as a String, performing automatic type conversion as necessary.

public int
size()

Get the number of arguments in this accessor.

public @Nullable Object[]
toArray()

Get all arguments in this accessor as an array.

public List<@Nullable Object>
toList()

Get all arguments in this accessor as an immutable list.

Method Detail

getback to summary
public @Nullable Object get(int index) throws ArgumentAccessException

Get the value of the argument at the given index as an Object.

Parameters
index:int

the index of the argument to get; must be greater than or equal to zero and less than size

Returns:@Nullable Object

the value at the given index, potentially null

getback to summary
public <T> @Nullable T get(int index, Class<T> requiredType) throws ArgumentAccessException

Get the value of the argument at the given index as an instance of the required type.

Parameters
index:int

the index of the argument to get; must be greater than or equal to zero and less than size

requiredType:Class<T>

the required type of the value; never null

Returns:@Nullable T

the value at the given index, potentially null

getBooleanback to summary
public @Nullable Boolean getBoolean(int index) throws ArgumentAccessException

Get the value of the argument at the given index as a Boolean, performing automatic type conversion as necessary.

Parameters
index:int

the index of the argument to get; must be greater than or equal to zero and less than size

Returns:@Nullable Boolean

the value at the given index, potentially null

Exceptions
ArgumentAccessException:
if the value cannot be accessed or converted to the desired type
getByteback to summary
public @Nullable Byte getByte(int index) throws ArgumentAccessException

Get the value of the argument at the given index as a Byte, performing automatic type conversion as necessary.

Parameters
index:int

the index of the argument to get; must be greater than or equal to zero and less than size

Returns:@Nullable Byte

the value at the given index, potentially null

Exceptions
ArgumentAccessException:
if the value cannot be accessed or converted to the desired type
getCharacterback to summary
public @Nullable Character getCharacter(int index) throws ArgumentAccessException

Get the value of the argument at the given index as a Character, performing automatic type conversion as necessary.

Parameters
index:int

the index of the argument to get; must be greater than or equal to zero and less than size

Returns:@Nullable Character

the value at the given index, potentially null

Exceptions
ArgumentAccessException:
if the value cannot be accessed or converted to the desired type
getDoubleback to summary
public @Nullable Double getDouble(int index) throws ArgumentAccessException

Get the value of the argument at the given index as a Double, performing automatic type conversion as necessary.

Parameters
index:int

the index of the argument to get; must be greater than or equal to zero and less than size

Returns:@Nullable Double

the value at the given index, potentially null

Exceptions
ArgumentAccessException:
if the value cannot be accessed or converted to the desired type
getFloatback to summary
public @Nullable Float getFloat(int index) throws ArgumentAccessException

Get the value of the argument at the given index as a Float, performing automatic type conversion as necessary.

Parameters
index:int

the index of the argument to get; must be greater than or equal to zero and less than size

Returns:@Nullable Float

the value at the given index, potentially null

Exceptions
ArgumentAccessException:
if the value cannot be accessed or converted to the desired type
getIntegerback to summary
public @Nullable Integer getInteger(int index) throws ArgumentAccessException

Get the value of the argument at the given index as a Integer, performing automatic type conversion as necessary.

Parameters
index:int

the index of the argument to get; must be greater than or equal to zero and less than size

Returns:@Nullable Integer

the value at the given index, potentially null

Exceptions
ArgumentAccessException:
if the value cannot be accessed or converted to the desired type
getInvocationIndexback to summary
public int getInvocationIndex()

Get the index of the current test invocation.

getLongback to summary
public @Nullable Long getLong(int index) throws ArgumentAccessException

Get the value of the argument at the given index as a Long, performing automatic type conversion as necessary.

Parameters
index:int

the index of the argument to get; must be greater than or equal to zero and less than size

Returns:@Nullable Long

the value at the given index, potentially null

Exceptions
ArgumentAccessException:
if the value cannot be accessed or converted to the desired type
getShortback to summary
public @Nullable Short getShort(int index) throws ArgumentAccessException

Get the value of the argument at the given index as a Short, performing automatic type conversion as necessary.

Parameters
index:int

the index of the argument to get; must be greater than or equal to zero and less than size

Returns:@Nullable Short

the value at the given index, potentially null

Exceptions
ArgumentAccessException:
if the value cannot be accessed or converted to the desired type
getStringback to summary
public @Nullable String getString(int index) throws ArgumentAccessException

Get the value of the argument at the given index as a String, performing automatic type conversion as necessary.

Parameters
index:int

the index of the argument to get; must be greater than or equal to zero and less than size

Returns:@Nullable String

the value at the given index, potentially null

Exceptions
ArgumentAccessException:
if the value cannot be accessed or converted to the desired type
sizeback to summary
public int size()

Get the number of arguments in this accessor.

toArrayback to summary
public @Nullable Object[] toArray()

Get all arguments in this accessor as an array.

toListback to summary
public List<@Nullable Object> toList()

Get all arguments in this accessor as an immutable list.