assert_running
TestApp::assert_running asserts the service is still up: no fail-fast failure has shut it down.
It is for a failure the service must survive.
Under the default FailurePolicy a delivery that does not decode is dropped, and the service keeps running; assert_last_failed_to_decode checks that delivery.
A handler panic under the default policy stops the service, and so does a decode failure under a fail_fast decode policy.
On failure the assertion names the failure that stopped the service.
assert_shut_down is the opposite assertion, and run_result gives the same state as a value.
Example
- Macros
- Manual
#[tokio::test]
async fn an_undecodable_order_does_not_stop_the_service() -> Result<(), Box<dyn Error>> {
let tb = TestApp::start(app()).await?;
tb.publish("orders", &json!({ "id": "seven" })).await?;
tb.broker::<MemoryBroker>()
.subscriber("orders")
.assert_called_once()
.assert_last_failed_to_decode();
tb.assert_running();
Ok(())
}
#[tokio::test]
async fn an_undecodable_order_does_not_stop_the_service() -> Result<(), Box<dyn Error>> {
let tb = TestApp::start(app()).await?;
tb.publish("orders", &json!({ "id": "seven" })).await?;
tb.broker::<MemoryBroker>()
.subscriber("orders")
.assert_called_once()
.assert_last_failed_to_decode();
tb.assert_running();
Ok(())
}