Testing: Assertions and History
world.then verifies what the system under test communicated. All checks are synchronous: they inspect the history recorded up to that point and throw a plain Error on failure. world.history exposes the same records directly for custom inspection, and PostboyWorldVerifier offers the same checks as booleans.
then.fired(type)
Returns a PostboyFiredThen<T> builder over the recorded messages of that type.
Exact counts:
Payload predicates:
Reading a message:
Chaining assertions - .and() returns the then service for the next check:
then.notFired(type)
Throws when any message of the type was recorded. Use it for negative cases after the act.
then.subscribed(type)
Every sub or once call on the mock bus increments a counter per type. subscribed returns a builder over that counter: once(), times(n), atLeast(n), and .and().
Subscriptions are counters - .with, .first, and .last do not exist here.
MessageHistory
world.history is the store behind then. Reach for it when the declarative API is not enough: ordering, index access, or custom filtering.
Callback messages record their results too:
Subscription counts and reset:
PostboyWorldVerifier
Non-throwing boolean counterparts. The world has no verifier getter - construct it over the world's history:
Prefer then for straight assertions - it fails with a descriptive error. Use the verifier inside conditional test logic where a boolean fits better.
Pitfalls
then.fired(X)returns a builder, not a boolean. A bareworld.then.fired(X)asserts nothing - finish the chain with.once(),.times(n), or a similar check..valueis the last message, not the first. Usehistory.messages(X).firstfor the earliest..withscans the whole collection; combine it with.once()when exactly one matching message must exist.Assertions are synchronous. For messages that arrive later, wait first - see Async waiters.
Next steps
Async waiters: waiting for messages that have not fired yet.
Recipes: full test scenarios built on these assertions.
PostboyWorld: the world fixture, strict mode, and dispose.
API reference: exact signatures.