Skip to content

Testing

Anvil supports several testing layers.

Test domain code directly. Pure business logic tests can run without Anvil.

Use app.Wire(anvilgen.Wiring()) in tests when you want explicit generated wiring.

transport := httpstd.New()
app := anvil.New(
httpstd.DriverFrom(transport),
anvil.WithProviders(anvil.As[project.Store](fakeStore)),
)
if err := app.Wire(anvilgen.Wiring()); err != nil {
t.Fatal(err)
}

Use testbeds for route-level protocol assertions generated or scripted from the manifest.

Use benchmarks when you need latency, allocation, throughput, or profiling data. The performance guide explains the core engine benchmarks, golden backend benchmarks, live HTTP/2 concurrency runs, and profiling commands.

If you write custom Starlark rules, test them with fixtures. A rule that blocks generation needs clear diagnostics and stable output.