Trait

org.scalatest

Status

Related Doc: package scalatest

Permalink

sealed trait Status extends AnyRef

The result status of running a test or a suite, which is used to support parallel and asynchronous execution of tests.

This trait is the result type of the "run" lifecycle methods of trait Suite: run, runNestedSuites, runTests, and runTest. It can be used to determine whether a test or suite has completed, and if so, whether it succeeded, and if not, whether an exception was thrown that was not yet reported via a ScalaTest event. A Status is like a domain-specific Future[Boolean], where:

One use case of Status is to ensure that "after" code (such as an afterEach or afterAll method) does not execute until after the relevant entity (a single test or all tests and nested suites) has completed. Another use case is to implement the default behavior of asynchronous styles, in which subsequent each test does not begin execution until after the previous test has completed.

Self Type
Status
Linear Supertypes
AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Status
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def isCompleted: Boolean

    Permalink

    Non-blocking call that indicates whether the all the tests or nested suites fired off by the run method that returned the Status have completed.

    Non-blocking call that indicates whether the all the tests or nested suites fired off by the run method that returned the Status have completed. Because this is non-blocking, you can use this to poll the completion status.

    Note: this method will not indicate whether a test has failed, suite has aborted, or an unreported exception has been installed. It just indicates whether the Status has completed or not by returning true or false.

    returns

    true if the test or suite run is already completed, false otherwise.

  2. abstract def whenCompleted(callback: (Try[Boolean]) ⇒ Unit): Unit

    Permalink

    Registers the passed callback function to be executed when this status completes.

    Registers the passed callback function to be executed when this status completes.

    If an unreported exception has been installed on this Status, the Try passed into the callback function will be a Failure containing that exception. Otherwise the Try will be a Success containing true if no tests failed or suites completed during the activity represented by this Status, else false.

    You may register multiple callback functions, which on completion will be executed in an undefined order.

    The callback functions registered with whenCompleted will be executed after the Status has completed. If the Status has already completed, functions passed to this method will be executed immediately by the calling thread before returning.

    Any exception thrown by a callback function will be propagated back on the thread used to invoke the callback.

    callback

    the callback function to execute once this Status has completed

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  7. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  8. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  9. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  10. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  11. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  12. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  13. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  14. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  15. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  16. final def thenRun(f: ⇒ Status): Status

    Permalink

    Registers a Status-producing by-name function to execute after this Status completes, returning a Status that mirrors the Status returned by the by-name.

    Registers a Status-producing by-name function to execute after this Status completes, returning a Status that mirrors the Status returned by the by-name.

    This method is used by async styles to ensure that by default, each subsequent test in an async-style suite begins execution only after the previous test has completed. This method is not used if ParallelTestExection is mixed into an async style. Instead, tests are allowed to begin execution concurrently.

    The Status returned by this method will completes when the status produced by the Status produced by the passed-by name completes. The returned Status will complete with the same succeeds and unreportedException values. But unlike the Status produced by the by-name, the returned Status will be available immediately.

    If a by-name function passed to this method

    returns

    a Status that represents the status of executing the by-name function passed to this method.

  17. final def toFuture: Future[Boolean]

    Permalink

    Converts this Status to a Future[Boolean] where Success(true) means no tests failed and suites aborted, Success(false), means at least one test failed or one suite aborted and those events were reported via the Reporter, Failure(ex) means a suite aborted but the exception, ex, was not reported to the Reporter.

    Converts this Status to a Future[Boolean] where Success(true) means no tests failed and suites aborted, Success(false), means at least one test failed or one suite aborted and those events were reported via the Reporter, Failure(ex) means a suite aborted but the exception, ex, was not reported to the Reporter.

  18. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  19. def unreportedException: Option[Throwable]

    Permalink

    An exception that was not reported by the activity represented by this Status.

    An exception that was not reported by the activity represented by this Status.

    When a test executes, "non-test-fatal" thrown exceptions are reported by the events fired to the reporter. A TestPendingException is reported via a TestPending event. A TestCanceledException is reported via a TestCanceled event. Any other non-test-fatal exceptions, including TestFailedException will be reported via a TestFailed event.

    Test-fatal exceptions indicate critical problems, such as OutOfMemoryError, that instead of being reported via a test completion event should instead cause the entire suite to abort. In synchronous testing styles, this exception will be allowed to just propagate up the call stack. But in async styles, the thread or threads executing the test will often be taken from the async suite's execution context. Instead of propagating these test-fatal exceptions up the call stack, they will be installed as an "unreported exception" in the test's Status. They are "unreported" because no test completion event will be fired to report them. For more explanation and a list of test-fatal exception types, see Treatment of java.lang.Errors.

    Another way for an unreported exception to occur is if an exception of any type is thrown outside of the body of an actual test. For example, traits BeforeAndAfter, BeforeAndAfterEach, and BeforeAndAfterEachTestData execute code before and after tests. Traits BeforeAndAfterAll and BeforeAndAfterAllConfigMap execute code before and after all tests and nested suites. If any "before" or "after" code completes abruptly with an exception (of any type, not just test-fatal types) on a thread taken from an async suite's execution context, this exception will installed as an unreportedException of the relevant Status. TODO: Is that true. Tests will tell.

    In addition, ScalaTest Suite exposes four "run" lifecycle methods--run, runNestedSuites, runTests, and runTest--that users can override to customize the framework. If a "run" lifecycle methods completes abruptly with an exception, that exception occurs outside the context of a test body. As a result, such exceptions will be installed as an unreportedException of the relevant Status.

    The toFuture method on Status returns a Future[Boolean]. If the Future succeeds with the Boolean value of true, that indicates no tests failed and no suites aborted during the activity represented by this Status. If a test failed or suite aborted, and that event was reported by a fired ScalaTest Event, the Future will succeed with the value false. If an unreported exception has been installed on the Status, however, the Future will fail with that exception.

  20. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  21. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  22. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  23. final def withAfterEffect(f: ⇒ Unit): Status

    Permalink

    Registers a by-name function (producing an optional exception) to execute after this Status completes.

    Registers a by-name function (producing an optional exception) to execute after this Status completes.

    This method is used by traits BeforeAndAfter, BeforeAndAfterAllConfigMap, BeforeAndAfterEach, and BeforeAndAfterEachTestData to ensure "after" code is executed after the relevant test completes, or the case of BeforeAndAfterAll, tests and nested suites complete. BeforeAndAfterAll,

    So what's wierd about this one is that I have it returning Option[Throwable], because that was what I had in hand, but I need to specify what happens if the method throws an exception anyway, so maybe it should be thrown instead of optionally returned. Also, what happens if it is a test-aborting exception. I think what should happen is it shows up in the status as an unreportedException, but wrapped in an ExecutionException. This would simplify the thing. Then also what happens if it is that, is the inner exception, the real one is allowed to propagate up the call stack.

Inherited from AnyRef

Inherited from Any

Ungrouped