final class StatefulStatus extends Status with Serializable
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.
- Source
- Status.scala
- Alphabetic
- By Inheritance
- StatefulStatus
- Serializable
- Status
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
-  new StatefulStatus()
Value Members
-   final  def !=(arg0: Any): Boolean- Definition Classes
- AnyRef → Any
 
-   final  def ##: Int- Definition Classes
- AnyRef → Any
 
-   final  def ==(arg0: Any): Boolean- Definition Classes
- AnyRef → Any
 
-   final  def asInstanceOf[T0]: T0- Definition Classes
- Any
 
-    def clone(): AnyRef- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
 
-   final  def eq(arg0: AnyRef): Boolean- Definition Classes
- AnyRef
 
-    def equals(arg0: AnyRef): Boolean- Definition Classes
- AnyRef → Any
 
-    def finalize(): Unit- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
 
-   final  def getClass(): Class[_ <: AnyRef]- Definition Classes
- AnyRef → Any
- Annotations
- @native()
 
-    def hashCode(): Int- Definition Classes
- AnyRef → Any
- Annotations
- @native()
 
-    def isCompleted(): BooleanNon-blocking call that returns trueifsetCompletedhas been invoked on this instance,falseotherwise.Non-blocking call that returns trueifsetCompletedhas been invoked on this instance,falseotherwise.- returns
- trueif the test or suite run is already completed,- falseotherwise.
 - Definition Classes
- StatefulStatus → Status
 
-   final  def isInstanceOf[T0]: Boolean- Definition Classes
- Any
 
-   final  def ne(arg0: AnyRef): Boolean- Definition Classes
- AnyRef
 
-   final  def notify(): Unit- Definition Classes
- AnyRef
- Annotations
- @native()
 
-   final  def notifyAll(): Unit- Definition Classes
- AnyRef
- Annotations
- @native()
 
-    def setCompleted(): UnitSets 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 Statusto completed.This method invokes any callbacks that have been registered with whenCompletedusing 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 withwhenCompletedwill be executed using the thread that invokedwhenCompleted.
-    def setFailed(): UnitSets 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 Statusto failed, but only up untilsetCompletedhas been called. OncesetCompletedhas been called, invoking this method will result in a thrownIllegalStateException.- Exceptions thrown
- IllegalStateExceptionif this method is invoked on this instance after- setCompletedhas been invoked on this instance.
 
-    def setFailedWith(ex: Throwable): UnitSets 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 Statusto failed, but only up untilsetCompletedhas been called. OncesetCompletedhas been called, invoking this method will result in a thrownIllegalStateException. Also, only the first exception passed will be reported as the unreported exception. Any exceptions passed via subsequent invocations ofsetFailedWithafter the first will have their stack traces printed to standard output.- ex
- an unreported exception 
 - Exceptions thrown
- IllegalStateExceptionif this method is invoked on this instance after- setCompletedhas been invoked on this instance.
 
-    def succeeds(): BooleanBlocking call that waits until completion, as indicated by an invocation of setCompletedon this instance, then returnsfalseifsetFailedwas called on this instance, else returnstrue.Blocking call that waits until completion, as indicated by an invocation of setCompletedon this instance, then returnsfalseifsetFailedwas called on this instance, else returnstrue.- returns
- trueif no tests failed and no suites aborted,- falseotherwise
 - Definition Classes
- StatefulStatus → Status
 
-   final  def synchronized[T0](arg0: => T0): T0- Definition Classes
- AnyRef
 
-   final  def thenRun(f: => Status): StatusRegisters a Status-producing by-name function to execute after thisStatuscompletes, returning aStatusthat mirrors theStatusreturned by the by-name.Registers a Status-producing by-name function to execute after thisStatuscompletes, returning aStatusthat mirrors theStatusreturned by the by-name.The Statusreturned by this method will complete when the status produced by theStatusproduced by the passed-by name completes. The returnedStatuswill complete with the samesucceedsandunreportedExceptionvalues. But unlike theStatusproduced by the by-name, the returnedStatuswill 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 unreportedExceptionon theStatusreturned by this method. TheStatusreturned 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 newjava.util.concurrent.ExecutionExceptionthat contains the run-aborting exception as its cause will be installed as theunreportedExceptionon theStatusreturned by this method. TheStatusreturned 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 ParallelTestExectionis mixed into an async style. Instead, tests are allowed to begin execution concurrently.- returns
- a - Statusthat represents the status of executing the by-name function passed to this method.
 - Definition Classes
- Status
 
-   final  def toFuture: Future[Boolean]Converts this Statusto aFuture[Boolean]whereSuccess(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 theReportervia a ScalaTest event,Failure(unreportedException)means an exception,unreportedException, was thrown that was not reported to theReportervia a ScalaTest event.Converts this Statusto aFuture[Boolean]whereSuccess(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 theReportervia a ScalaTest event,Failure(unreportedException)means an exception,unreportedException, was thrown that was not reported to theReportervia a ScalaTest event.- returns
- a - Future[Boolean]representing this- Status.
 - Definition Classes
- Status
 
-    def toString(): String- Definition Classes
- AnyRef → Any
 
-    def unreportedException: Option[Throwable]An exception that was thrown during the activity represented by this Statusthat was not reported via a ScalaTest event fired to theReporter.An exception that was thrown during the activity represented by this Statusthat was not reported via a ScalaTest event fired to theReporter.When a test executes, "non-run-aborting" thrown exceptions are reported by events fired to the reporter. A TestPendingExceptionis reported via aTestPendingevent. ATestCanceledExceptionis reported via aTestCanceledevent. Any other non-run-aborting exceptions, includingTestFailedExceptionwill be reported via aTestFailedevent.Run-aborting 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 run-aborting exceptions up the call stack, they will be installed as an "unreported exception" in the test'sStatus. They are "unreported" because no test completion event will be fired to report them. For more explanation and a list of run-aborting exception types, see Treatment ofjava.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, andBeforeAndAfterEachTestDataexecute code before and after tests. TraitsBeforeAndAfterAllandBeforeAndAfterAllConfigMapexecute code before and after all tests and nested suites of a suite. If any "before" or "after" code completes abruptly with an exception (of any type, not just run-aborting types) on a thread taken from an async suite's execution context, this exception will installed as anunreportedExceptionof the relevantStatus.In addition, ScalaTest Suiteexposes four "run" lifecycle methods--run,runNestedSuites,runTests, andrunTest--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 anunreportedExceptionof the relevantStatus.The toFuturemethod onStatusreturns aFuture[Boolean]. If theFuturesucceeds with theBooleanvalue oftrue, that indicates no tests failed and no suites aborted during the activity represented by thisStatus. If a test failed or suite aborted, and that event was reported by a fired ScalaTestEvent, theFuturewill succeed with the valuefalse. If an unreported exception has been installed on theStatus, however, theFuturewill fail with that exception.- returns
- a optional unreported - Throwable
 - Definition Classes
- StatefulStatus → Status
 
-   final  def wait(): Unit- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
 
-   final  def wait(arg0: Long, arg1: Int): Unit- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
 
-   final  def wait(arg0: Long): Unit- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
 
-    def waitUntilCompleted(): UnitBlocking call that returns only after setCompletedhas been invoked on thisStatefulStatusinstance.Blocking call that returns only after setCompletedhas been invoked on thisStatefulStatusinstance.- Definition Classes
- StatefulStatus → Status
 
-    def whenCompleted(f: (Try[Boolean]) => Unit): UnitRegisters the passed function to be executed when this status completes. Registers the passed function to be executed when this status completes. You may register multiple functions, which on completion will be executed in an undefined order. - Definition Classes
- StatefulStatus → Status
 
-   final  def withAfterEffect(f: => Unit): StatusRegisters a by-name function (producing an optional exception) to execute after this Statuscompletes.Registers a by-name function (producing an optional exception) to execute after this Statuscompletes.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 unreportedExceptionon theStatusreturned by this method. TheStatusreturned 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 newjava.util.concurrent.ExecutionExceptionthat contains the run-aborting exception as its cause will be installed as theunreportedExceptionon theStatusreturned by this method. TheStatusreturned 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 theStatusreturned by this method.Internally, ScalaTest uses this method in traits BeforeAndAfter,BeforeAndAfterEach, andBeforeAndAfterEachTestDatato ensure "after" code is executed after the relevant test has completed, and in traitsBeforeAndAfterAllandBeforeAndAfterAllConfigMapto ensure "after" code is executed after the relevant tests and nested suites have completed.- f
- A by-name function to invoke after this - Statushas completed.
- returns
- a - Statusthat represents this- Status, modified by any exception thrown by the passed by-name function.
 - Definition Classes
- Status