trait
CompleteLastly extends AnyRef
Type Members
-
Value Members
-
final
def
!=(arg0: Any): Boolean
-
final
def
##(): Int
-
final
def
==(arg0: Any): Boolean
-
final
def
asInstanceOf[T0]: T0
-
def
clone(): AnyRef
-
-
final
def
eq(arg0: AnyRef): Boolean
-
def
equals(arg0: Any): Boolean
-
def
finalize(): Unit
-
final
def
getClass(): Class[_]
-
def
hashCode(): Int
-
final
def
isInstanceOf[T0]: Boolean
-
final
def
ne(arg0: AnyRef): Boolean
-
final
def
notify(): Unit
-
final
def
notifyAll(): Unit
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
-
def
toString(): String
-
final
def
wait(): Unit
-
final
def
wait(arg0: Long, arg1: Int): Unit
-
final
def
wait(arg0: Long): Unit
Inherited from AnyRef
Value Members
-
final
def
!=(arg0: Any): Boolean
-
final
def
##(): Int
-
final
def
==(arg0: Any): Boolean
-
def
clone(): AnyRef
-
final
def
eq(arg0: AnyRef): Boolean
-
def
equals(arg0: Any): Boolean
-
def
finalize(): Unit
-
final
def
getClass(): Class[_]
-
def
hashCode(): Int
-
final
def
ne(arg0: AnyRef): Boolean
-
final
def
notify(): Unit
-
final
def
notifyAll(): Unit
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
-
def
toString(): String
-
final
def
wait(): Unit
-
final
def
wait(arg0: Long, arg1: Int): Unit
-
final
def
wait(arg0: Long): Unit
Inherited from Any
Value Members
-
final
def
asInstanceOf[T0]: T0
-
final
def
isInstanceOf[T0]: Boolean
Ungrouped
-
final
def
!=(arg0: Any): Boolean
-
final
def
##(): Int
-
final
def
==(arg0: Any): Boolean
-
final
def
asInstanceOf[T0]: T0
-
def
clone(): AnyRef
-
-
final
def
eq(arg0: AnyRef): Boolean
-
def
equals(arg0: Any): Boolean
-
def
finalize(): Unit
-
final
def
getClass(): Class[_]
-
def
hashCode(): Int
-
final
def
isInstanceOf[T0]: Boolean
-
final
def
ne(arg0: AnyRef): Boolean
-
final
def
notify(): Unit
-
final
def
notifyAll(): Unit
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
-
def
toString(): String
-
final
def
wait(): Unit
-
final
def
wait(arg0: Long, arg1: Int): Unit
-
final
def
wait(arg0: Long): Unit
Trait that provides a
complete
-lastly
construct, which ensures cleanup code inlastly
is executed whether the code passed tocomplete
completes abruptly with an exception or successfully results in aFuture
,FutureOutcome
, or other type with an implicitFuturistic
instance.This trait is mixed into ScalaTest's async testing styles, to make it easy to ensure cleanup code will execute whether code that produces a "futuristic" value (any type
F
for which aFuturistic[F]
instance is implicitly available). ScalaTest provides implicitFuturistic
instances forFuture[T]
for any typeT
andFutureOutcome
.If the future-producing code passed to
complete
throws an exception, the cleanup code passed tolastly
will be executed immediately, and the same exception will be rethrown, unless the code passed tolastly
also completes abruptly with an exception. In that case,complete
-lastly
will complete abruptly with the exception thrown by the code passed tolastly
(this mimics the behavior offinally
).Otherwise, if the code passed to
complete
successfully returns aFuture
(or other "futuristic" type),complete
-lastly
will register the cleanup code to be performed once the future completes and return a new future that will complete once the original future completes and the subsequent cleanup code has completed execution. The future returned bycomplete
-lastly
will have the same result as the original future passed tocomplete
, unless the cleanup code throws an exception. If the cleanup code passed tolastly
throws an exception, the future returned bylastly
will fail with that exception.The
complete
-lastly
syntax is intended to be used to ensure cleanup code is executed in async testing styles liketry
-finally
is used in traditional testing styles. Here's an example ofcomplete
-lastly
used inwithFixture
in an async testing style: