ulo
ulo
Documentation

Start here

Coming from NestJSNestJS topics, mapped

The model

Protocols

Integrations

Operating

TestingTestAppClocks in testsAsserting failures

Reference

Testing

Testing

Testing an application from a plain function call up to a served app on a scripted clock.

An application is built from values, so a test chooses how much of it to start. The cost goes up with each step, and each step catches a different mistake.

What the test doesCatchesCosts
Calls a constructor or method directlyLogic in one typeNothing.
wire() and reads the errorMissing, ambiguous, cyclic and mis-scoped bindings, before any instance existsNo I/O.
connect() and app.get::<T>()Constructors, readiness checks, hooks, module visibilityBuilds the singletons.
Binds a server on port 0 and sends requestsRoutes, extractors, the pipelineA socket per test.
Runs on a scripted clockDeadlines, drains, backoffA few lines of setup.

TestApp is exported from ulo; ulo::testing exports the clock helpers. A constructor-style provider's new is an ordinary function. A test calls it with Dep::from_arc(Arc::new(..)) arguments and no container. Reach for the container when the test is about something it does: visibility, scope, hooks or the wiring itself.

TestApp

The production module graph with values, factories and whole modules replaced.

Clocks in tests

Tokio's paused clock, and ScriptedTimer for apps that own servers.

Asserting failures

Reading wiring, connect and load refusals as data.

Every example under examples/ ships its tests, and the pages here quote them: examples/13-testing is the one about TestApp.

The ex_support helpers in those tests (start, listen, get) belong to the examples workspace (examples/support), not to a published crate. The page for TestApp shows what listen does so a test can write the same three calls.

Moving from axum or actix-web

Move an existing axum or actix-web app onto Ulo one route at a time, with Ulo as the host's fallback service, and a contract test that diffs old and new answers.

TestApp

Replacing a mock, a factory or a whole module in the production graph, and the refusals that keep a stale mock from passing.