@API(status=EXPERIMENTAL,
since="5.4")
public interface TestInstances
TestInstances
encapsulates the test instances of a test.
While top-level tests only have a single test instance, nested tests have one additional instance for each enclosing test class.
ExtensionContext.getTestInstances()
,
ExtensionContext.getRequiredTestInstances()
Modifier and Type | Method and Description |
---|---|
<T> Optional<T> |
findInstance(Class<T> requiredType)
Find the first test instance that is an instance of the supplied required
type, checking from innermost to outermost.
|
List<Object> |
getAllInstances()
Get all test instances, ordered from outermost to innermost.
|
List<Object> |
getEnclosingInstances()
Get the enclosing test instances, excluding the innermost test instance,
ordered from outermost to innermost.
|
Object |
getInnermostInstance()
Get the innermost test instance.
|
Object getInnermostInstance()
The innermost instance is the one closest to the test method.
null
List<Object> getEnclosingInstances()
null
or containing
null
, but potentially emptyList<Object> getAllInstances()
null
, containing null
,
or empty<T> Optional<T> findInstance(Class<T> requiredType)
requiredType
- the type to search fornull
but potentially emptyCopyright © 2021. All rights reserved.