Module org.junit.jupiter.engine
Class DefaultTestInstances
- java.lang.Object
-
- org.junit.jupiter.engine.execution.DefaultTestInstances
-
- All Implemented Interfaces:
TestInstances
@API(status=INTERNAL, since="5.4") public class DefaultTestInstances extends Object implements TestInstances
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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.static DefaultTestInstances
of(Object instance)
static DefaultTestInstances
of(TestInstances testInstances, Object instance)
-
-
-
Method Detail
-
of
public static DefaultTestInstances of(Object instance)
-
of
public static DefaultTestInstances of(TestInstances testInstances, Object instance)
-
getInnermostInstance
public Object getInnermostInstance()
Description copied from interface:TestInstances
Get the innermost test instance.The innermost instance is the one closest to the test method.
- Specified by:
getInnermostInstance
in interfaceTestInstances
- Returns:
- the innermost test instance; never
null
-
getEnclosingInstances
public List<Object> getEnclosingInstances()
Description copied from interface:TestInstances
Get the enclosing test instances, excluding the innermost test instance, ordered from outermost to innermost.- Specified by:
getEnclosingInstances
in interfaceTestInstances
- Returns:
- the enclosing test instances; never
null
or containingnull
, but potentially empty
-
getAllInstances
public List<Object> getAllInstances()
Description copied from interface:TestInstances
Get all test instances, ordered from outermost to innermost.- Specified by:
getAllInstances
in interfaceTestInstances
- Returns:
- all test instances; never
null
, containingnull
, or empty
-
findInstance
public <T> Optional<T> findInstance(Class<T> requiredType)
Description copied from interface:TestInstances
Find the first test instance that is an instance of the supplied required type, checking from innermost to outermost.- Specified by:
findInstance
in interfaceTestInstances
- Parameters:
requiredType
- the type to search for- Returns:
- the first test instance of the required type; never
null
but potentially empty
-
-