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 be === 3 }
Companion object that facilitates the importing of
Payloads
members as an alternative to mixing it in. One use case is to importPayloads
members so you can use them in the Scala interpreter.