Перейти к основному содержимому
Эта страница ещё не переведена

Ниже показан английский оригинал.

panicked

panicked() checks that the handler panicked on its latest call.

The harness runs dispatch under the app's real failure policy. Under the default policy, fail_fast, a panic shuts the service down, which tb.assert_shut_down() states. The delivery stays unsettled, so no settled(..) matches it; assert_outcome(Outcome::Panicked) is the same check by outcome. The test output carries the handler's panic message, and the test itself passes. assert_last_failed_to_decode checks the other failure a call can end in. The assert_shut_down and run_result pages show what the panic did to the service.

Example​

#[tokio::test]
async fn a_panic_stops_the_service() -> Result<(), Box<dyn Error>> {
let tb = TestApp::start(app()).await?;
let broker = tb.broker::<MemoryBroker>();
broker
.message(&Order { id: 0 })
.to("orders")
.publish()
.await?;

broker.subscriber("orders").assert_called_once().panicked();
tb.assert_shut_down();
Ok(())
}