Skip to main content

Testing

Every layer below is runnable locally through the Makefile, and every make target mirrors a job in .github/workflows/ci.yml. Numbers on this page were counted from the repository at the time of writing.

The layers​

LayerWhat it coversWhereNeedsRun it
UnitAggregates and invariants (internal/domain/**), use cases with fakes and in-memory adapters (internal/application/usecases), adapters with httptest and fake readers/writers (HTTP handlers, Kafka encode/decode, golden CloudEvents JSON, MCP tools). 92 non-integration _test.go files.next to the codeGo onlymake test (go test ./... -race)
Coverage gateStatement coverage of internal/domain/... and internal/application/... must be ≥ 90%.–Gomake coverage
IntegrationReal Postgres and Kafka started per test run with testcontainers-go (modules/postgres, modules/kafka); no DATABASE_URL, no compose. 24 files tagged //go:build integration.see the list belowDockermake integration (go test -tags=integration ./... -race -count=1)
BDD (Gherkin)Business rules as black-box scenarios: the real chi router behind httptest, in-memory repositories, a buffered publisher and a fixed clock (ADR-0007).features/*.feature, run by TestFeatures in features_test.goGomake bdd (go test ./... -run TestFeatures -v)
ContractProperty-based conformance of the running API to apis/openapi.yaml (Schemathesis 4.28.0).scripts/contract-test.sh, schemathesis.tomlGo, Python stmake contract
MutationDo the tests assert, not just execute? gremlins v0.6.0 with thresholds from .gremlins.yaml..gremlins.yamlgremlinsmake mutation-fast, make mutation
Architecture fitnessThe hexagonal dependency rule and fleet rules as Go tests (ADR-0006).internal/architecture/Gomake arch-test
MCP evalsE1 schema/metadata, E2 wire conformance, E3 behavioural Gherkin over the Streamable HTTP handler.internal/adapters/inbound/mcp/eval_*_test.go, evalsuite_test.go, testdata/features/mcp_tools.featureGogo test ./internal/adapters/inbound/mcp/... -race -run '^TestEval|^TestMCPEvalSuite' -v
Chart render testsProbes, MCP env, Service selectors and sweep CronJobs render as intended; the api Deployment mounts the env ConfigMap with envFrom (D14) and OUTBOX_MAX_ATTEMPTS defaults to 20 (D12), no other workload mounts it.charts/fulfillment-execution/tests/*.py, charts/fulfillment-execution/tests/render_test.shPython (PyYAML), bash, helmbash charts/fulfillment-execution/tests/render_test.sh, python3 charts/fulfillment-execution/tests/test_sweeps_cronjob.py (one script per file); all four run in the chart-tests CI job
FrontendThe web/ micro-frontend: lint, type check, unit tests, build.web/Node 22npm test in web/

Integration suites​

All tagged integration. Each package starts its own containers; the postgres and inbound/http packages share one migrated Postgres per package run through main_integration_test.go:

  • internal/adapters/outbound/postgres: repositories, the claim compare-and-set race, the consolidation race, the outbox and relay, pool limits and statement_timeout, rehydration validation, source order and line number, transfer details, the RELOCATE move and its executed result (task_relocation_integration_test.go, migration 0019) and the REPLENISH move and its executed result (task_replenishment_integration_test.go, migration 0020, with its down).
  • internal/adapters/inbound/http: the Idempotency-Key middleware against a real transaction.
  • internal/adapters/inbound/kafka: the DLQ, the ProductClassified consumer, line_no bounds, transfer facts end to end (Kafka + Postgres), and a RELOCATE release completed into a TaskCompleted with the relocation fields end to end (relocation_integration_test.go, ADR-0047), and a REPLENISH release completed into a TaskCompleted with request_ref end to end, with the atomicity of creation and completion (replenishment_integration_test.go, ADR-0050).
  • internal/adapters/outbound/kafka: hash partitioning by aggregate key and CloudEvents on the wire.
  • internal/adapters/outbound/kafkacatalog: catalogue replay against a real broker.
  • internal/adapters/outbound/analyticsstore: projection and read-only report store.
  • internal/adapters/outbound/productclassificationcopy: the version-guarded upsert.
  • internal/adapters/inbound/mcp: the Streamable HTTP transport over Postgres.
  • internal/application/usecases: use cases wired to real adapters.
  • cmd/mcp: complete_task writing the outbox.

make integration and the CI integration job both run go test -tags=integration ./..., so a new suite is picked up without editing either. The fitness tests TestKafkaIntegrationTestsUseTestcontainers and TestPostgresIntegrationTestsUseTestcontainers fail the build if a test gates on an external KAFKA_BROKERS or DATABASE_URL instead of starting a container.

BDD features​

21 feature files with 92 Scenario/Scenario Outline headings (6 are outlines, expanded by their example tables):

Feature fileScenarios
claim_next.feature3
claim_next_validation.feature3
complete_task.feature2
cpt_missed_sweep.feature4
cpt_sweep_boundaries.feature2
installed_capacity.feature2
lease.feature2
order_ref_lookup.feature3
pack_slam.feature4
package_read_model.feature6
rebin_consolidation.feature6
request_validation.feature17 (5 outlines)
seal_package_guards.feature4
slam_required_weights.feature4
slam_tolerance.feature1
station_and_claim_selection.feature3
station_occupancy.feature4
task_creation.feature2
task_guards.feature6
task_lifecycle_edges.feature9
work_released_consumer.feature5 (1 outline)

The MCP E3 suite adds 17 scenarios in internal/adapters/inbound/mcp/testdata/features/mcp_tools.feature. The fixed clock is what lets a scenario assert lease expiry without sleeping.

Contract tests​

scripts/contract-test.sh builds cmd/execution, writes a four-path catalogue (PICK, PACK, REBIN, SLAM) to a temp dir, boots the service in memory on 127.0.0.1:18082 (override with CONTRACT_PORT), waits for /healthz, then runs st run apis/openapi.yaml --max-examples 100 --workers 4 (CONTRACT_MAX_EXAMPLES overrides the count). sealPackage is excluded, because success needs a PACK task claimed by the same station, which OpenAPI cannot express; schemathesis.toml widens accepted statuses for arriveAtRebin only (a 422 rebin-unknown-line on a schema-valid body). Install with python3 -m pip install 'schemathesis==4.28.0'.

Mutation testing​

TargetScopeWhenGate
make mutation-fast / CI mutation-fast./internal/domain/task (claim, lease, at-most-once, CPT-missed)every push and PRefficacy ≥ 90%, mutant coverage ≥ 90%
make mutation / CI mutation./internal/domain (--workers 1 --timeout-coefficient 30)weekly schedule and manual dispatchsame thresholds

The thresholds live in .gremlins.yaml (threshold.efficacy: 90.0, threshold.mutant-coverage: 90.0).

Architecture fitness tests​

internal/architecture/ (make arch-test):

TestGuards
TestHexagonalDependencyRulesdomain imports nothing internal but domain; application only domain; inbound and outbound adapters never import each other; only cmd wires everything
TestAnalyticsIsolationRulesinternal/analytics/** imports nothing else from the module, and domain/application never import it (ADR-0012)
TestMCPAdapterDependencyRulethe MCP adapter depends only on application and domain, and nothing depends on it
TestRepositoryPortImplementersFollowRepoNamingConventionevery struct implementing the TaskRepo port is named ...Repo
TestEventCatalogueMatchesContract, TestEventCatalogueDetectorthe published CloudEvents types match apis/asyncapi.yaml
TestCloudEventsOnlyno flat-envelope code path comes back (ADR-0032)
TestReplayConsumersSetCommitIntervalfull-replay consumers commit asynchronously
TestNoAuthMiddlewareReintroducedREST/MCP stay unauthenticated (ADR-0022)
TestKafkaConsumerGroupNeverHardcodedInlineno Kafka GroupID is assigned from an inline string literal (it must come from a named constant, an env lookup or a function)
TestKafkaIntegrationTestsUseTestcontainers, TestPostgresIntegrationTestsUseTestcontainers, TestPostgresIntegrationDetectorintegration tests start their own containers
TestMCPOptionalToolInputsCarryOmitempty, TestMCPOptionalToolInputsSensorFailsOnBadFixturesan MCP tool input field whose jsonschema description says "optional" carries omitempty, or the SDK marks it required (gap fix D16; the twin proves the sensor fails on a bad fixture)
TestOutboxRelaysPassAttemptCap, TestOutboxRelayCapSensorFailsOnBadFixturesevery NewOutboxRelay call under cmd/ or internal/composition/ passes WithMaxAttempts (ADR-0042, gap fix D12)
TestKafkaWritersSetRequiredAcks, TestKafkaWriterAcksSensorBitesEvery kafka-go Writer composite literal in a non-test file under internal/ or cmd/ sets RequiredAcks (the import alias is resolved per file). kafka-go defaults it to RequireNone (acks=0): the broker never confirms the write, so a broker blip silently drops the message while WriteMessages returns nil. The twin proves the sensor flags a bad fixture under any alias.
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.)

Gap-fix wave (2026-10-12) tests outside internal/architecture:

TestGuards
TestEvalConformance_InstructionsNameTheWriteToolthe MCP instructions do not call the server read-only and name complete_task (D17)
TestReportTools_OptionalFiltersAreOptionalOnTheWireboth report tools advertise required: [from, to] and a call without filters reaches the handler (D16)
TestNewLoggerLevels (one per cmd/*)LOG_LEVEL warn/warning, case-insensitive, in every binary (D22)
TestOutboxRelay_MaxAttempts_PoisonRowExcludedThenGoodRowPublishes, TestOutboxRelay_MaxAttempts_ReArmedRowIsClaimedAgain, TestOutboxRelay_NoCap_PoisonRowBlocksLaterRows (integration, testcontainers)the relay attempt cap: a poison row is excluded after N failures and logged at ERROR, the same-key row behind it publishes, the re-arm SQL works, 0 keeps the old blocking behaviour (D12)
TestOutboxTrace_TraceparentCrossesTheOutboxToKafka, TestOutboxTrace_RowWithoutTraceHeadersRelaysUnchanged (integration, testcontainers Postgres + Kafka)the request span's traceparent is stored in outbox_events.headers, relayed by a span-less relay pass to a real broker and extracted by a consumer as the same parent; a row without trace headers relays unchanged (D27; characterisation tests, the behaviour already existed)
TestReportsSpecAndRouterAgree, TestReportsResponsesConformToSpecapis/openapi-reports.yaml and NewReportsRouter agree on routes (both directions), statuses, media types and properties (D18, ADR-0043)
TestOutboxMaxAttempts, TestBuildEventPublisher_KafkaWithPoolUsesOutboxOUTBOX_MAX_ATTEMPTS parsing (default 20, 0 unlimited, bad value falls back) and the cap reaching the relay (D12)

Local gates and hooks​

TargetRuns
make checkfmt-check vet build lint test: the fast bundle
make check-allcheck + coverage arch-test bdd: the fuller gate
make check-fastfmt-check vet arch-test plus tests of the Go packages changed vs HEAD (agent stop hook)
make vulngovulncheck ./...
make guide-lint, make harness-testagent-guide lint and hook tests

lefthook.yml (activate once with lefthook install): pre-commit runs make fmt-check, make vet, make lint; pre-push runs make check. golangci-lint is pinned to v2.13.1.

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

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

JobRunsWhen
lintgolangci-lint v2.13.1every push/PR
guide-lintscripts/harness/guide_lint.py, repo_lint.py, test_hook.py, test_repo_lint.pyevery push/PR
complexitygolangci-lint with only gocyclo,gocognit,cyclop,funlen,nestif, plus an informational gocyclo reportevery push/PR
testbuild, vet, then make coverage (go test ./... -race with the Makefile's coverage scope and 90% gate)every push/PR
bddgo test ./... -run TestFeatures -vevery push/PR
contractscripts/contract-test.sh with Schemathesis 4.28.0every push/PR
evals-testsMCP evals (^TestEval and ^TestMCPEvalSuite)every push/PR
integrationgo test -tags=integration ./... -race -count=1every push/PR
mutation-fastgremlins unleash ./internal/domain/taskevery push/PR
vulngovulncheck v1.8.0every push/PR
api-lintSpectral on apis/openapi.yaml, apis/openapi-reports.yaml and apis/asyncapi.yamlevery push/PR
docs-api-driftnpm run clean-api-docs:all && npm run gen-api-docs:all in docs/, fail on a diff or an untracked page under docs/api-reference/rest or docs/api-reference/rest-reportsevery push/PR
arch-testgo test ./internal/architecture/... -vevery push/PR
webbuilds warehouse-ui-kit develop, then lint, tsc -b, npm test, build of web/every push/PR
mutationfull domain mutation run; opens/closes a harness:red issueschedule and dispatch only
driftdeadcode, go mod tidy -diff, knip on web/, coverage-quality report (advisory)schedule and dispatch only
helm-lintchart-testing lintpull requests into main only
chart-testsbash charts/fulfillment-execution/tests/render_test.sh, then the three Python chart tests with PyYAML 6.0.3 pinned (so they cannot SKIP)every push/PR (gap fix D25)
trivy-scanimage build plus Trivy (blocks on fixable CRITICAL/HIGH)pull requests into main only
docker-publishbuild, push, cosign sign, SBOM attestpush to main only
releaseversion tag, Helm chart push to oci://ghcr.io/iqvo, GitHub releasepush to main only

Other workflows: codeql.yml (push/PR to main and develop, weekly), scorecard.yml (push to develop, weekly), ai-review.yml (PRs into develop touching domain, application, apis/ or charts/), and docs.yml, which builds the site (npm run typecheck, npm run build) on every pull request touching docs/** and deploys it only on push to main (the PR trigger is gap fix D25; before it, a broken sidebar id or link was found only after release).

Source: .github/workflows/ci.yml (docker-publish.needs, release.needs).