StatefulStatus
Status implementation that can change its state over time.
A StatefulStatus begins its life in a successful state, and will remain successful unless setFailed is called.
Once setFailed is called, the status will remain at failed. The setFailed method can be called multiple times (even
though invoking it once is sufficient to permanently set the status to failed), but only up until setCompleted has been called.
After setCompleted has been called, any invocation of setFailed will be greeted with an IllegalStateException.
Instances of this class are thread safe.
Value members
Concrete methods
Non-blocking call that returns true if setCompleted has been invoked on this instance, false otherwise.
Non-blocking call that returns true if setCompleted has been invoked on this instance, false otherwise.
- Returns:
trueif the test or suite run is already completed,falseotherwise.
Sets the status to completed.
Sets the status to completed.
This method may be invoked repeatedly, even though invoking it once is sufficient to set the state of the Status to completed.
This method invokes any callbacks that have been registered with whenCompleted using the thread that invoked
this method prior to declaring this status as completed. This method then executes any callbacks that were registered between
thie time this method decided it was done executing previously registered callbacks and the time it declared this status as
completed. This second pass ensures no callbacks are lost. Any subsequent callbacks registered with whenCompleted
will be executed using the thread that invoked whenCompleted.
Sets the status to failed without changing the completion status.
Sets the status to failed without changing the completion status.
This method may be invoked repeatedly, even though invoking it once is sufficient to set the state of the Status to failed, but only
up until setCompleted has been called. Once setCompleted has been called, invoking this method will result in a
thrown IllegalStateException.
- Throws:
- IllegalStateException
if this method is invoked on this instance after
setCompletedhas been invoked on this instance.
Sets the status to failed with an unreported exception, without changing the completion status.
Sets the status to failed with an unreported exception, without changing the completion status.
This method may be invoked repeatedly, even though invoking it once is sufficient to set the state of the Status to failed, but only
up until setCompleted has been called. Once setCompleted has been called, invoking this method will result in a
thrown IllegalStateException. Also, only the first exception passed will be reported as the unreported exception. Any exceptions
passed via subsequent invocations of setFailedWith after the first will have their stack traces printed to standard output.
- Value parameters:
- ex
an unreported exception
- Throws:
- IllegalStateException
if this method is invoked on this instance after
setCompletedhas been invoked on this instance.
Blocking call that waits until completion, as indicated by an invocation of setCompleted on this instance, then returns false
if setFailed was called on this instance, else returns true.
Blocking call that waits until completion, as indicated by an invocation of setCompleted on this instance, then returns false
if setFailed was called on this instance, else returns true.
- Returns:
trueif no tests failed and no suites aborted,falseotherwise
Blocking call that returns only after setCompleted has been invoked on this StatefulStatus instance.
Blocking call that returns only after setCompleted has been invoked on this StatefulStatus instance.
Inherited methods
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.
The Status returned by this method will complete 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 the by-name function passed to this method completes abruptly with a non-run-aborting exception,
that exception will be caught and installed as the unreportedException on the
Status returned by this method. The Status returned by this method
will then complete. The thread that attempted to evaluate the by-name function will be allowed
to continue (i.e., the non-run-aborting exception will not be rethrown
on that thread).
If the by-name function passed to this method completes abruptly with a run-aborting exception,
such as StackOverflowError, that exception will be caught and a new
java.util.concurrent.ExecutionException that contains the run-aborting exception as its
cause will be installed as the unreportedException on the
Status returned by this method. The Status returned by this method
will then complete. The original run-aborting exception will then be rethrown on the
thread that attempted to evaluate the by-name function.
If an unreported exception is installed on this Status, the passed by-name function will
still be executed.
Internally, ScalaTest uses this method in 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.
- Value parameters:
- status
A
Status-producing by-name function to invoke after thisStatushas completed.
- Returns:
a
Statusthat represents the status of executing the by-name function passed to this method.- Inherited from:
- Status
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 any thrown exception was was reported to the Reporter via a ScalaTest
event, Failure(unreportedException) means
an exception, unreportedException, was thrown that was not reported to the Reporter
via a ScalaTest event.
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 any thrown exception was was reported to the Reporter via a ScalaTest
event, Failure(unreportedException) means
an exception, unreportedException, was thrown that was not reported to the Reporter
via a ScalaTest event.
- Returns:
a
Future[Boolean]representing thisStatus.- Inherited from:
- Status
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.
If the by-name function passed to this method completes abruptly with a non-run-aborting exception,
that exception will be caught and installed as the unreportedException on the
Status returned by this method. The Status returned by this method
will then complete. The thread that attempted to evaluate the by-name function will be allowed
to continue (i.e., the non-run-aborting exception will not be rethrown
on that thread).
If the by-name function passed to this method completes abruptly with a run-aborting exception,
such as StackOverflowError, that exception will be caught and a new
java.util.concurrent.ExecutionException that contains the run-aborting exception as its
cause will be installed as the unreportedException on the
Status returned by this method. The Status returned by this method
will then complete. The original run-aborting exception will then be rethrown on the
thread that attempted to evaluate the by-name function.
If an unreported exception is installed on this Status, the passed by-name function will
not be executed. Instead, the same unreported exception will be installed on the Status
returned by this method.
Internally, ScalaTest uses this method in traits BeforeAndAfter,
BeforeAndAfterEach, and BeforeAndAfterEachTestData to ensure "after" code is
executed after the relevant test has completed, and in traits BeforeAndAfterAll and
BeforeAndAfterAllConfigMap to ensure "after" code is executed after the
relevant tests and nested suites have completed.
- Value parameters:
- f
A by-name function to invoke after this
Statushas completed.
- Returns:
a
Statusthat represents thisStatus, modified by any exception thrown by the passed by-name function.- Inherited from:
- Status