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 Details

    • 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 interface TestInstances
      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 interface TestInstances
      Returns:
      the enclosing test instances; never null or containing null, 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 interface TestInstances
      Returns:
      all test instances; never null, containing null, 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 interface TestInstances
      Parameters:
      requiredType - the type to search for
      Returns:
      the first test instance of the required type; never null but potentially empty