Class that provides the lastly method of the complete-lastly syntax.
Class that provides the lastly method of the complete-lastly syntax.
Registers a block of code that produces any "futuristic" type (any type F for which
an implicit Futuristic[F] instance is implicitly available), returning
an object that offers a lastly method.
Registers a block of code that produces any "futuristic" type (any type F for which
an implicit Futuristic[F] instance is implicitly available), returning
an object that offers a lastly method.
See the main documentation for trait CompleteLastly for more detail.
cleanup code to execute whether the code passed to complete
throws an exception or succesfully returns a futuristic value.
Trait that provides a
complete-lastlyconstruct, which ensures cleanup code inlastlyis executed whether the code passed tocompletecompletes abruptly with an exception or successfully results in aFuture,FutureOutcome, or other type with an implicitFuturisticinstance.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
Ffor which aFuturistic[F]instance is implicitly available). ScalaTest provides implicitFuturisticinstances forFuture[T]for any typeTandFutureOutcome.If the future-producing code passed to
completethrows an exception, the cleanup code passed tolastlywill be executed immediately, and the same exception will be rethrown, unless the code passed tolastlyalso completes abruptly with an exception. In that case,complete-lastlywill complete abruptly with the exception thrown by the code passed tolastly(this mimics the behavior offinally).Otherwise, if the code passed to
completesuccessfully returns aFuture(or other "futuristic" type),complete-lastlywill 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-lastlywill have the same result as the original future passed tocomplete, unless the cleanup code throws an exception. If the cleanup code passed tolastlythrows an exception, the future returned bylastlywill fail with that exception.The
complete-lastlysyntax is intended to be used to ensure cleanup code is executed in async testing styles liketry-finallyis used in traditional testing styles. Here's an example ofcomplete-lastlyused inwithFixturein an async testing style: