Skip to main content

Testing

The test pyramid as it is on develop. The pre-push gate is make check; CI runs the wider set below. All Go tests live next to the code they test, except the godog features (features/) and the architecture fitness tests (internal/architecture/). No Go file sits at the repo root (TestNoGoFilesAtRepoRoot).

The pyramid​

LayerWhereWhat it provesRun it
Unit (domain)internal/domain/{shared,wave,route,partner,history}/*_test.goaggregate invariants and state machines, snapshot rebuilds; no I/Omake test
Unit (use cases)internal/application/usecases/*_test.go over the in-memory doubles (internal/adapters/outbound/memory)every use case, fault paths (faults_test.go), the consumers' effects (consumers_test.go), the business counter (attempt_metrics_test.go)make test
Handler / adapterinternal/adapters/inbound/http (handlers, idempotency and its replay classes: the harness suite idempotency_replay_classes_test.go over the memory store, over Postgres in the integration build, plus replay_catalogue_test.go holding ADR 0019 and the OpenAPI text equal to the catalogue; NUL rejection, readiness), .../inbound/kafka (consume loop, dead letter, tracing), .../inbound/mcp (tools, governance), .../inbound/a2a (card, skills), .../outbound/{kafka,outbox,telemetry,system}, internal/adapters/kafka/cloudevents, cmd/* (config, wiring, telemetry, router)adapters in isolation with fakes; HTTP via httptestmake test
BDD (godog)features/*.feature: waves, routes, dispatch, partners, api and the rule files wave_rules, route_rules, partner_rules, rest_rules, delivery_point_rules, carrier_area_rules (11 files, 167 scenario definitions, 214 executed: definitions are the Scenario: and Scenario Outline: lines, git grep -c -E "^[[:space:]]*Scenario( Outline)?:" -- features, an Outline counts once; executed adds one run per Examples row and is the N scenarios line of go test ./features -run TestFeatures -v. Definitions / executed per file: waves 14 / 14, routes 11 / 11, dispatch 3 / 3, partners 3 / 3, api 12 / 12, wave_rules 36 / 48, route_rules 45 / 67, delivery_point_rules 15 / 22, carrier_area_rules 10 / 10, partner_rules 5 / 8, rest_rules 13 / 16), runner features/features_test.go (TestFeatures) with steps in steps_test.go, steps_dispatch_test.go, steps_http_test.go and the world_test.go fixturebusiness behaviour through the use cases and through the HTTP API on the in-memory doublesmake bdd
Integrationbuild tag integration: 9 files, 16 test functions: internal/adapters/outbound/postgres/*_integration_test.go (repositories, migrations, idempotency store, outbox trace), cmd/api/{wiring,e2e,idempotency,idempotency_replay}_integration_test.go (the last: concurrent-update and unknown-station release their key through the real router), cmd/mcp/main_integration_test.go, cmd/a2a/main_integration_test.goreal Postgres and real Kafka, started by testcontainers (helpers in internal/testing/pgtest and internal/testing/kafkatest); cmd/api boots run(ctx), drives REST and Kafka only, and stops Kafka to prove /readyz answers 503 dependency-unavailable while /healthz stays 200make integration (needs Docker)
Contractinternal/adapters/outbound/repocontract (one repository contract run against both the in-memory doubles and Postgres, so the doubles cannot drift); internal/adapters/inbound/mcp/testdata/tool_registry.golden.json (the MCP tool registry is golden-pinned); the encoder golden tests in internal/adapters/outbound/kafka/encoder_test.go; the event catalogue test against apis/asyncapi.yaml (TestEventCatalogueMatchesContract)published contracts match the codemake test, make arch-test
Mutation.gremlins.yaml, internal/domain/*tests assert, not just execute. Measured 2026-11-15: lowest package (deliverypoint) efficacy 97.62 %, mutant coverage 89.36 %, every other package 100 % (route 97.56 % mutant coverage); thresholds 97 / 89 (strictly below the lowest package; the residual mutants are listed in MUTATION.md)make mutation
Architecture fitnessinternal/architecture/*_test.go (15 files)the rules belowmake arch-test
Webweb/ (lint, tsc -b, vitest, build)the operator micro-frontendCI job web

What the fitness tests pin​

TestRule
TestHexagonalArchitecturethe domain imports no outer layer; adapters do not reach sideways into siblings
TestRuntimeBinaryHasNoInMemoryAdapters, TestRuntimeBinaryDoesNotImportTheRepositoryContractcmd/** never links the memory doubles or the repository contract
TestNoGoFilesAtRepoRootthe godog runner lives in features/, not at the root
TestCloudEventsOnly, TestNoEventEnvelopeToggleOrFlatEnvelope, TestEventCatalogueMatchesContractevery message is a CloudEvents 1.0 envelope built by internal/adapters/kafka/cloudevents; no toggle for a flat envelope; the catalogue matches apis/asyncapi.yaml
TestKafkaWritersSetRequiredAcks, TestKafkaWriterTopicNotSetTwice, TestDeadLetterCallsGuardCancellationproducers use acks=all; a writer sets its topic once (per message, never on both the Writer and the Message); dead-letter calls guard context cancellation
TestKafkaConsumerGroupNeverHardcodedInline, TestReplayConsumersSetCommitIntervalconsumer group ids come from the environment; commit interval stays unset so commits are synchronous
TestOutboxRelaysPassAttemptCapevery relay is built with WithMaxAttempts
TestMCPAdapterDependencyRule, TestMCPServerIsReadOnly, TestMCPOptionalToolInputsCarryOmitemptythe MCP adapter wires only read use cases and carries read-only annotations
TestA2AAdapterDependencyRule, TestA2AAgentIsReadOnlyAndHasNoOutboundClientthe A2A agent is read-only and has no outbound client
TestNoAuthMiddlewareReintroducedno bearer/JWT check under internal/adapters/inbound
TestKafkaIntegrationTestsUseTestcontainers, TestPostgresIntegrationTestsUseTestcontainersintegration tests start their own containers; none is gated by DATABASE_URL or KAFKA_BROKERS or skips

Each rule has a companion ...SensorBites / ...FailsOnBadFixtures test that feeds a bad fixture and asserts the rule fails, so a sensor cannot pass vacuously.

make targets​

TargetRuns
make checkfmt-check, vet, build, lint, test (go test ./... -race): the pre-push gate
make check-allcheck + coverage + arch-test + bdd
make check-fastfmt-check, vet, arch-test, then the tests of the changed packages (agent stop hook)
make testgo test ./... -race
make coveragethe same with -coverpkg=./internal/domain/...,./internal/application/...; fails below 90 %
make bddgo test ./... -run TestFeatures -v
make arch-testgo test ./internal/architecture/... -v
make integrationgo test -tags=integration ./... -race -count=1 (Docker)
make mutationgremlins per ./internal/domain/*/ package; make mutation-full runs ./internal/domain with --workers 1 --timeout-coefficient 30
make vulngovulncheck ./...
make lintgolangci-lint run --allow-parallel-runners ./... (v2.14.0 in CI)
make guide-lint, make harness-testagent-guide and hook checks

lefthook runs fmt-check, vet and lint on pre-commit and make check on pre-push (lefthook install once per clone).

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

Triggers: push and pull request on main and develop, a weekly Monday 06:00 UTC schedule, and manual dispatch.

JobWhat it does
lintgolangci-lint v2.14.0
guide-lintagent-guide linter and hook tests (advisory, continue-on-error)
complexitygocyclo, gocognit, cyclop, funlen, nestif via golangci-lint
testgo build, go vet, then make coverage (the only place the coverage scope and gate are defined)
bddgo test ./... -run TestFeatures -v
integrationgo test -tags=integration ./... -race -count=1 (testcontainers)
mutation-fastgremlins v0.6.0 over every internal/domain/*/ package; blocking
mutationexhaustive gremlins run; schedule and manual only; opens a harness:red issue on a scheduled failure
driftweekly advisory: dead code, go mod tidy -diff, knip on web/, coverage-quality; never blocks
api-lintSpectral on apis/openapi.yaml and apis/asyncapi.yaml (--fail-severity=warn)
vulngovulncheck ./...
helm-lintct lint and the selector test (pull requests only)
chart-testsevery charts/last-mile-delivery/tests/*.sh and test_*.py; fails on SKIP
arch-testthe fitness tests
weblint, tsc -b, tests and build of web/ against warehouse-ui-kit
docker-publish, releasepush to main only: signed image, SBOM, chart .tgz to oci://ghcr.io/iqvo, tag and GitHub release

This repository's documentation site has its own workflow, .github/workflows/docs.yml (builds on pull requests, deploys on push to main); there is no docs-api-drift job in ci.yml.

Writing a test​

  • A new use case: add a unit test over the in-memory doubles (helpers_test.go has the fixture), a fault case in faults_test.go, and a scenario in features/ if it is user-visible.
  • A new event: domain struct + apis/asyncapi.yaml + ADR 0004 type: line in the same commit, an encoder payload and a golden test; TestEventCatalogueMatchesContract fails otherwise.
  • A new repository method: extend the contract in internal/adapters/outbound/repocontract so both the double and Postgres are exercised.
  • Never gate an integration test on an environment variable or t.Skip; start the container with pgtest or kafkatest.