Class TestExecutionResult

java.lang.Object
org.junit.platform.engine.TestExecutionResult

@API(status=STABLE,
     since="1.0")
public class TestExecutionResult
extends Object
TestExecutionResult encapsulates the result of executing a single test or container.

A TestExecutionResult consists of a mandatory Status and an optional Throwable.

Since:
1.0
  • Method Details

    • successful

      public static TestExecutionResult successful()
      Create a TestExecutionResult for a successful execution of a test or container.
      Returns:
      the TestExecutionResult; never null
    • aborted

      public static TestExecutionResult aborted​(Throwable throwable)
      Create a TestExecutionResult for an aborted execution of a test or container with the supplied throwable.
      Parameters:
      throwable - the throwable that caused the aborted execution; may be null
      Returns:
      the TestExecutionResult; never null
    • failed

      public static TestExecutionResult failed​(Throwable throwable)
      Create a TestExecutionResult for a failed execution of a test or container with the supplied throwable.
      Parameters:
      throwable - the throwable that caused the failed execution; may be null
      Returns:
      the TestExecutionResult; never null
    • getStatus

      public TestExecutionResult.Status getStatus()
      Get the status of this result.
      Returns:
      the status; never null
    • getThrowable

      public Optional<Throwable> getThrowable()
      Get the throwable that caused this result, if available.
      Returns:
      an Optional containing the throwable; never null but potentially empty
    • toString

      public String toString()
      Overrides:
      toString in class Object