@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> java.util.Optional<T> |
findInstance(java.lang.Class<T> requiredType)
Find the first test instance that is an instance of the supplied required
type, checking from innermost to outermost.
|
java.util.List<java.lang.Object> |
getAllInstances()
Get all test instances, ordered from outermost to innermost.
|
java.util.List<java.lang.Object> |
getEnclosingInstances()
Get the enclosing test instances, excluding the innermost test instance,
ordered from outermost to innermost.
|
java.lang.Object |
getInnermostInstance()
Get the innermost test instance.
|
java.lang.Object getInnermostInstance()
The innermost instance is the one closest to the test method.
null
java.util.List<java.lang.Object> getEnclosingInstances()
null
or containing
null
, but potentially emptyjava.util.List<java.lang.Object> getAllInstances()
null
, containing null
,
or empty<T> java.util.Optional<T> findInstance(java.lang.Class<T> requiredType)
requiredType
- the type to search fornull
but potentially empty