fork
abstract fun fork(name: String = "", verifyError: Boolean = false, block: ForkedVerifiedStageDsl<S>.() -> Unit)
Creates a branching test scenario from the current verified state.
This method allows testing multiple command sequences or alternative scenarios starting from the same verified aggregate state. Each fork creates an isolated test context that can execute additional commands and expectations.
Example usage:
whenCommand(CreateOrderCommand(...)) {
expectEventType(OrderCreated::class)
fork("Pay Order") {
whenCommand(PayOrderCommand(...)) {
expectEventType(OrderPaid::class)
}
}
fork("Cancel Order") {
whenCommand(CancelOrderCommand(...)) {
expectEventType(OrderCancelled::class)
}
}
}Content copied to clipboard
Parameters
name
optional descriptive name for the forked scenario
verifyError
whether to verify that an error occurred before forking
block
the test scenario to execute in the forked context