Payloads

object Payloads extends Payloads

Companion object that facilitates the importing of Payloads members as an alternative to mixing it in. One use case is to import Payloads members so you can use them in the Scala interpreter.

Companion:
class
trait Payloads
class Object
trait Matchable
class Any

Value members

Inherited methods

def withPayload[T](payload: => Any)(fun: => T): T

Executes the block of code passed as the second parameter, and, if it completes abruptly with a ModifiablePayload exception, replaces the current payload contained in the exception, if any, with the one passed as the first parameter.

Executes the block of code passed as the second parameter, and, if it completes abruptly with a ModifiablePayload exception, replaces the current payload contained in the exception, if any, with the one passed as the first parameter.

This method allows you to insert a payload into a thrown Payload exception (such as a TestFailedException), so that payload can be included in events fired to a custom reporter that can make use of the payload. Here's an example in which a GUI snapshot is included as a payload when a test fails:

withPayload(generateGUISnapshot()) {
 1 + 1 should === (3)
}
Inherited from:
Payloads