Skip to main content

Testing

Every layer below exists in the repository today. Counts were taken from the develop tree on 2026-10-12 (func Test… declarations, Gherkin Scenario: headings); they drift as tests are added. The BDD counts were re-measured on 2026-11-15, after the documentation-derived scenarios.

Source: features/*.feature, **/*_test.go, .github/workflows/ci.yml, Makefile.

Make targets​

TargetCommandNeeds
make testgo test ./... -raceGo only
make coveragego test ./... -race -coverprofile=coverage.out -coverpkg=./internal/domain/...,./internal/application/... and the 90 % gate on the totalGo only
make bddgo test ./... -run TestFeatures -vGo only
make arch-testgo test ./internal/architecture/... -vGo only
make integrationgo vet -tags=integration ./... then go test -tags=integration ./... -race -count=1Docker (each test starts its own containers)
make contract./scripts/contract-test.shst from schemathesis==4.28.0, a free port (default 18084)
make mutation-fastgremlins unleash ./internal/domain/ordergremlins v0.6.0
make mutationgremlins unleash ./internal/domain --workers 1 --timeout-coefficient 30gremlins v0.6.0; slow
make vulngovulncheck ./...govulncheck
make chart-testbash charts/order-management/tests/render_test.sh then python3 charts/order-management/tests/test_service_selectors.pyhelm, Python 3 with PyYAML
make checkfmt-check vet build lint testgolangci-lint v2.13.1
make check-allcheck coverage arch-test bddas above
make check-fastfmt-check vet arch-test plus the tests of packages changed against HEADused by the agent Stop hook
make guide-lint, make harness-testscripts/harness/guide_lint.py, scripts/harness/test_hook.pyPython 3

lefthook.yml runs make fmt-check, make vet and make lint before each commit and make check before each push, once a clone has run lefthook install.

Unit tests​

  • Domain (internal/domain/order, processpath, shared, releaseconfirmation): the aggregate, line state machine, status derivation, promise policy and promise groups, path selection and eligibility, planned-capacity windows, and the release-confirmation state machine (PENDING -> CONFIRMED, PENDING -> UNCONFIRMED once, late and duplicate confirmation, the overdue boundary; ADR 0043). Pure Go, no fakes needed. path_selection_intake_test.go pins ADR 0042: only CUSTOMER_ORDER paths are candidates, and the live catalogue before seeding (PACK/PICK/REBIN/SLAM at 2h, no intake) resolves to pick, never PACK.
  • Application (internal/application/usecases): every use case against in-memory repositories and the fakes in fakes_test.go (inventory client, publisher, metrics counter, clock). release_confirmation_test.go pins ADR 0043: the PENDING row is written in the release's own unit of work (a later failure rolls it back) and only for lines released in that pass, an event without reference/line_no or for an unknown line is ignored and counted without opening a transaction, and the timeout sweep flags overdue rows exactly once (0 disables it).
  • Adapters: the HTTP router through httptest (status codes, problem types, idempotency, readiness, logging), the Kafka consumers against fake readers and DLQ writers (release_confirmation_consumer_test.go: fixture JSON with and without the new fields, malformed data to the DLQ, unknown types committed past, shutdown never dead-letters), the publishers against fake writers, the inventory-storage client against a fake HTTPDoer, the circuit breaker, the telemetry instruments (including the two release-confirmation counters), the composition root's wiring helpers in cmd/order (release_confirmation_test.go: the RELEASE_CONFIRMATION_* boot validation, the 15m and 168h defaults).
  • Golden files pin wire formats: internal/adapters/outbound/kafka (cloudevents_golden_test.go), internal/adapters/outbound/events/testdata/log_payloads.golden, internal/adapters/inbound/mcp/testdata/tool_registry.golden and fleet_tool_snapshot.golden.

Coverage is measured on internal/domain/... and internal/application/... only, and must stay at or above 90 %.

Integration tests (-tags=integration)​

Every suite starts its own throwaway container with testcontainers-go v0.44.0 (postgres and kafka modules). There is no shared DATABASE_URL, no t.Skip on a missing environment variable, and no localhost:9092: the architecture fitness tests below fail the build if one appears. Postgres packages migrate once into a template database and clone one database per test.

PackageFilesWhat it proves
cmd/order1The housekeeping sweeper wiring against real Postgres.
internal/adapters/inbound/http2The Idempotency-Key middleware and the router over real Postgres.
internal/adapters/inbound/kafka8Re-promise consumer end to end, its version-conflict retry, its DLQ (including auto-creating a missing .dlq topic), the planned-capacity and product-classification consumers, the consumer-shutdown dead-letter guard, and the release-confirmation consumer (release_confirmation_consumer_integration_test.go, ADR 0043: a produced WorkUnitCreated CloudEvent ends CONFIRMED, a malformed one lands in the DLQ, and cancelling Run mid-handle returns nil with the DLQ empty).
internal/adapters/inbound/mcp1initialize, tools/list and tools/call over the real Streamable HTTP transport, with real Postgres (OLTP and analytics) behind it.
internal/adapters/outbound/analyticsstore2Projection and report queries.
internal/adapters/outbound/kafka1Publisher on a real broker, CloudEvents envelope asserted.
internal/adapters/outbound/kafkacatalog, kafkacptschedule, kafkapathcapacity3, 1, 1The replay caches, including two catalogue consumers side by side, and the catalogue's decoded intake driving PathSelectionPolicy on a real broker (TestConsumer_RealBroker_IntakeDrivesPathSelection, ADR 0042).
internal/adapters/outbound/postgres10Order repository and version column, outbox and relay, outbox lag gauge, release events through the outbox, planned capacity, pool limits (MaxConns, statement_timeout), sweeper, trace headers through the outbox, and the release-confirmation repository and sweeper hook (release_confirmation_integration_test.go, ADR 0043, including two concurrent sweepers flagging a row once).
internal/adapters/outbound/productclassificationcopy1The Postgres copy and its version guard.
internal/application/usecases1Receive, allocate, release, retry, cancel against the real repository and UnitOfWork.

The CI job and make integration both use ./.... TestEveryIntegrationPackageRunsInCI fails if a package with a //go:build integration file is not reached by an integration command in ci.yml. In CI, TESTCONTAINERS_RYUK_DISABLED=true is set because the parallel test processes contend for the reaper.

BDD (godog)​

TestFeatures (features_test.go at the repo root) runs every file in features/ with Strict: true, so an undefined or pending step fails the suite. Step definitions live in features_test.go, features_planned_capacity_test.go, features_fulfillment_site_test.go, features_wave2_test.go, steps_rules_test.go and steps_closeout_test.go. The scenarios drive the use cases, and for the REST contract scenarios the router through httptest, all on in-memory adapters.

The default tag filter is ~@known-bug; BDD_TAGS overrides it (BDD_TAGS=@known-bug go test . -run TestFeatures runs only the tagged scenarios). No scenario carries @known-bug today; the tag and the filter stay for the next documented-but-unimplemented rule. The former occupant, "A shipped order can no longer be cancelled" (event_driven_rules.feature), passes by default since Order.EnsureCancellable rejects a Shipped line as well as a Released one (internal/domain/order/order.go, ADR 0004 addendum 2026-11-15).

Feature fileScenarios
allocation_events.feature5
allocation_failure.feature2
api_contract.feature8
cancellation.feature2
cancellation_extended.feature2
domain_events.feature2
error_paths.feature4
event_driven_rules.feature32 (consumer rules driven through the use cases: repromise ADR 0018, release confirmation ADR 0043, shipment ADR 0051, missed load, shipped order not cancellable)
fulfillment_site.feature7
held_orders.feature5
held_orders_extended.feature3
intake_validation.feature4
mutation_closeout.feature10 (rules the first rule files left unpinned: found by mutation)
order_lifecycle.feature2
order_rules.feature55 (REST-reachable documented rules: intake, path selection, allocation and retry, held orders, cancellation, promise policy, demand projection, readiness)
partial_shipment.feature2
planned_capacity.feature10
planned_capacity_extended.feature5
required_ship_by.feature2
ship_complete.feature2
20 files164

The counts are Scenario and Scenario Outline definitions (git grep -c -E "^[[:space:]]*Scenario" -- features). With outline rows expanded the runner executes 195 scenarios, none skipped by the default filter.

Contract tests (Schemathesis)​

scripts/contract-test.sh builds cmd/order, starts it in memory on 127.0.0.1:${CONTRACT_PORT:-18084} with PLANNED_CAPACITY_CONSUMER_GROUP=contract-test-planned-capacity and PLANNED_CAPACITY_SITE_ID=SIM1 (so GET /planned-capacity exists), waits for /healthz, then runs Schemathesis 4.28.0 with CONTRACT_MAX_EXAMPLES (default 100) examples per operation against apis/openapi.yaml. receiveOrder is excluded, because the "held order must be ship-complete" rule links two booleans in a way OpenAPI 3.0 cannot express; the BDD scenario and the domain unit test cover it instead.

cmd/order-reports needs an analytical database to start, so its contract, apis/openapi-reports.yaml (ADR 0039), is checked by two Go tests in the test job instead of Schemathesis: TestReportsContract_RoutesMatchSpec (the chi router's routes equal the spec's paths) and TestReportsContract_ResponsesMatchSpec (every documented status of every operation, driven through a stub store, answers a declared status and media type with exactly the documented properties).

Mutation testing (gremlins)​

Thresholds live in .gremlins.yaml: efficacy 97, mutant-coverage 99, with workers: 1 and timeout-coefficient: 30. gremlins fails when the measured value is less than or equal to the threshold. The last recorded run (2026-10-10, ./internal/domain/order) measured 137 killed, 3 lived, 1 not covered: efficacy 97.86 %, mutant coverage 99.29 %. The three survivors are listed as accepted near-equivalents in the README.

Architecture fitness tests (internal/architecture)​

TestRule
TestHexagonalDependencyRuledomain imports nothing internal; application imports only domain; inbound and outbound adapters never import each other; only cmd/ wires every layer.
TestAnalyticsIsolationinternal/analytics never imports the OLTP layers (ADR 0006).
TestPortsAreCustomerOwnedinternal/application/ports never imports an adapter or cmd/ (ADR 0002).
TestMCPAdapterDependencyRulethe MCP adapter depends only on application and domain, and nothing else imports it.
TestNoAuthMiddlewareReintroducedno bearer-auth middleware comes back (ADR 0012).
TestKafkaConsumerGroupNeverHardcodedInlineconsumer groups are named constants or configuration.
TestKafkaIntegrationTestsUseTestcontainers, TestPostgresIntegrationTestsUseTestcontainersno env-gated or localhost:9092 integration tests.
TestDomainHasNoSerializationTagsno json: tags in internal/domain.
TestCloudEventsOnly, TestReplayConsumersSetCommitIntervalevery Kafka message goes through the CloudEvents helper; replay readers set CommitInterval.
TestKafkaWritersSetRequiredAcks, TestKafkaWriterAcksSensorBitesevery kafka-go Writer{...} literal in a non-test file under internal/ or cmd/ sets RequiredAcks (kafka-go defaults to RequireNone, acks=0, which silently drops messages on a broker blip); the sensor is proven to fail.
TestDeadLetterCallsGuardCancellation (+ TestDeadLetterShutdownSensorBites, kafka_dlq_shutdown_fitness_test.go)Every function in a non-test file under internal/adapters/inbound/kafka that sends to the dead-letter topic must reference ctx.Err() (any context-named value) or context.Canceled in its own body, or carry a //dlq:deterministic <reason> comment on the call line or the line above it. A handler that fails because the process is stopping must not dead-letter a good message and commit past it (network-fulfillment #89); a guard in the caller does not count. The sensor test proves the detector flags the pre-fix shape.
TestKafkaWriterTopicNotSetTwice (+ TestKafkaWriterTopicSensorBites, kafka_writer_topic_fitness_test.go)kafka-go rejects every write whose Message.Topic is set when the Writer also has a Topic. Per Go package under internal/ and cmd/: once any kafka-go Message literal sets Topic, every Writer literal in that package must leave Topic empty, unless it carries //kafka:fixed-topic-writer <reason> and no Topic-setting Message is provably written through it. Writers configured after construction and WriterConfig are not covered. (Escape: warehouse-planning's domain DLQ writer, where no dead letter ever landed.)
TestEventCatalogueMatchesContractevery CloudEvents type apis/asyncapi.yaml declares for this service also appears in an ADR (the event catalogue).
TestOptionalMCPInputsCarryOmitemptya struct field whose jsonschema description says "optional" carries omitempty, so the MCP SDK does not mark it required (fleet decision D16).
TestEveryIntegrationPackageRunsInCIsee above.

Several sensors have a companion test (TestPostgresIntegrationDetector, TestEventCatalogueDetector, TestDomainTagSensorFailsOnBadFixtures, TestIntegrationCoverageSensorFailsOnBadFixtures, TestOptionalMCPInputSensorFailsOnBadFixtures) that proves the sensor flags a known-bad fixture.

MCP evals (internal/adapters/inbound/mcp)​

LevelTestsWhat
E1 governanceTestEval_InputSchemasResolveAndConstrain, TestEval_ParametersAreDescribed, TestEval_ToolRegistryMatchesGolden, TestEval_FleetToolNamesAreGloballyUniqueSchemas resolve, every parameter has a description, the registry matches tool_registry.golden, tool names are unique across the fleet snapshot.
E2 conformancenine TestEvalConformance_* testsHandshake, unknown tool, wrong-typed and extra arguments, exactly one resource template and one prompt advertised (ADR 0049), session close.
E3 behaviourTestMCPEvalSuite13 scenarios in testdata/features/mcp_tools.feature, run through godog with Strict: true.

Frontend (web/)​

Vitest tests (src/config.test.ts, src/api.test.ts, src/screens/OrderManagementScreen.test.tsx, with an MSW mock server) run in the web CI job together with lint, tsc -b and the production build. They are not part of make check. api.test.ts and four screen cases pin the Idempotency-Key contract of ADR 0038 (a UUID per submission, reused when the request got no answer, new after an answer or an edit); TestCORS_PreflightAllowsIdempotencyKey pins the CORS side.

The chart has a selector test, python3 charts/order-management/tests/test_service_selectors.py (make chart-test), which proves each Service selects exactly one Deployment and that the startupProbe outlasts the boot retry budget. The chart-tests CI job runs it on every push and PR with Helm v3.16.4 and PyYAML; without PyYAML the script fails instead of skipping. Before it, the same job runs charts/order-management/tests/render_test.sh (helm only), which asserts the api Deployment mounts the chart ConfigMap with envFrom (gap fix D14), that config.outboxRelayInterval and config.outboxMaxAttempts reach it (default OUTBOX_MAX_ATTEMPTS 20, ADR 0040), that the housekeeping keys render only with a database, and that the projector, reports and MCP Deployments do not mount it.

The outbox relay attempt cap (ADR 0040) is pinned by TestOutboxRelay_MaxAttempts_PoisonRowIsExcludedAndTheNextRowPublishes and TestOutboxRelay_WithoutMaxAttempts_RetriesWithoutBound (testcontainers Postgres, internal/adapters/outbound/postgres/outbox_integration_test.go), TestOutboxMaxAttemptsFromEnv (cmd/order), and the architecture fitness test TestOutboxRelayCallsSetMaxAttempts, which fails when a file under cmd/ builds a relay without WithMaxAttempts.

Trace continuity across the outbox (ADR 0041, the fleet D27 reference) is pinned by TestOutboxTrace_TraceparentCrossesTheOutboxToKafka and TestOutboxTrace_RowWithoutTraceHeadersRelaysUnchanged (internal/adapters/outbound/postgres/outbox_trace_integration_test.go, integration tag). They boot the package's shared Postgres container plus their own Kafka container: a use case runs inside a request span, the relay sends the row on a context without that span, and the consumed message's traceparent must extract to the request's trace and span.

CI jobs (.github/workflows/ci.yml)​

JobRunsWhen
lintgolangci-lint v2.13.1every push and PR
guide-lintguide_lint.py, repo_lint.py, test_hook.py, test_repo_lint.pyevery push and PR
complexitygolangci-lint with only gocyclo, gocognit, cyclop, funlen, nestif; gocyclo > 10 reportevery push and PR
testbuild, vet, gofmt, then make coverage (go test ./... -race with the Makefile's coverage scope and 90 % gate)every push and PR
bddgo test ./... -run TestFeatures -vevery push and PR
contractscripts/contract-test.shevery push and PR
evals-testsgo test ./internal/adapters/inbound/mcp/... -race -run '^TestEval|^TestMCPEvalSuite' -vevery push and PR
integrationgo vet -tags=integration ./..., go test -tags=integration ./... -race -count=1every push and PR
mutation-fastgremlins unleash ./internal/domain/orderevery push and PR
vulngovulncheck v1.8.0every push and PR
api-lintSpectral on apis/openapi.yaml, apis/openapi-reports.yaml and apis/asyncapi.yamlevery push and PR
arch-testgo test ./internal/architecture/... -vevery push and PR
docs-api-driftclean-api-docs:all + gen-api-docs:all; fails on any change under docs/docs/api-reference/rest or rest-reportsevery push and PR
webMFE lint, typecheck, test, buildevery push and PR
chart-testscharts/order-management/tests/render_test.sh and test_service_selectors.py (Helm v3.16.4, PyYAML)every push and PR
mutationfull-domain gremlins; opens or closes a harness:red issueschedule (Mondays 06:00 UTC) and manual dispatch
driftdeadcode, go mod tidy -diff, knip, coverage qualityschedule and manual dispatch
helm-lint, trivy-scanchart-testing lint; image scanPRs into main only
docker-publish, releasepush the image, tag, chart and GitHub releasepushes to main only

The documentation site is built by .github/workflows/docs.yml on every pull request that touches docs/**, apis/** or the workflow (build only, no Pages artifact, no deploy) and built and published on pushes to main. Run npm ci and npm run build in docs/ to reproduce it locally.