Scenario structure
scenario(name: string, body: Fn)
Register a named scenario, run in isolation (fresh agents, torn down
after). The body may take the setup() context: |ctx| { … }.
Example
#![allow(unused)]
fn main() {
scenario("answered call", |ctx| {
ctx.caller.dial(ctx.callee);
await_until(|| assert(ctx.callee.state).equals(State::Ringing), "15s");
ctx.callee.accept();
});
}
scenario(name: string, options: map, body: Fn)
Register a scenario with options #{ tags: ["smoke"], skip: true|"reason", only: true }. --tag/--exclude-tag filter by tag; a skipped scenario is
reported but not run; if any scenario sets only, only those run.
setup(body: Fn)
Run before each scenario; its return value is passed to the scenario
(and teardown) as ctx. Typically creates and registers the agents.
Example
#![allow(unused)]
fn main() {
setup(|| {
let caller = agent("Caller", #{ username: env("A_USER"), domain: env("SIP_DOMAIN"), password: env("A_PASS") });
caller.register();
#{ caller: caller }
});
}
skip()
Skip the current scenario at runtime (reported, not failed).
skip(reason: string)
Skip the current scenario at runtime with a reason (reported, not failed);
e.g. if env("STAGE") != "prod" { skip("prod only") }.
Example
#![allow(unused)]
fn main() {
if env("STAGE") != "prod" { skip("prod only") }
}
teardown(body: Fn)
Run after each scenario (even on failure); receives the setup context.