Make assertions respect when statements