Skip to main content

start_live

start_live connects the brokers of the same app to a running stand, so one test body checks the service against the real broker.

It is for a stand of a networked broker: a Kafka or NATS server the test suite starts beside the tests. Each broker connects through its ordinary connect, and the rest of startup is the production one. The test body is the one an in-process test runs; only the start call differs from TestApp::start. MemoryBroker connects without a server, so the example runs in process in every mode. A publish, settle and advance wait on the real clock until every subscription has handled what was published to it. The wait lasts ten seconds at most; start_live_within sets another bound, and past it the call fails with TestError::NotSettled naming the subscription. A live test runs on the real clock: start_live on a paused clock fails with TestError::PausedClock. The test's input reaches the broker through its connected form's default publish policy.

Example​

#[tokio::test]
async fn against_the_stand() -> Result<(), Box<dyn Error>> {
accepts_an_order(TestApp::start_live(app()).await?).await
}

#[tokio::test]
async fn against_a_distant_stand() -> Result<(), Box<dyn Error>> {
let tb = TestApp::start_live_within(app(), Duration::from_secs(30)).await?;
accepts_an_order(tb).await
}