Testing
Counts below were taken from the tree on this branch: 152 *_test.go files, of
which 40 carry the integration build tag; 27 Gherkin files with 172 scenario
definitions under features/ (249 scenarios executed once every Examples row
of a Scenario Outline is counted), plus 1 MCP feature file with 9 scenarios
(definitions counted by Scenario and Scenario Outline; executed counts are
the N scenarios line of go test . -run TestFeatures -count=1 -v).
Source: Makefile, .github/workflows/ci.yml, .gremlins.yaml, features/, internal/architecture/.
Make targets
make help prints the list. Every target mirrors a CI job.
| Target | Runs | Needs |
|---|---|---|
make build / make vet | go build ./... / go vet ./... | Go |
make fmt / make fmt-check | gofmt -w . / fail on any unformatted file | Go |
make lint | golangci-lint run ./... (CI pins v2.13.1) | golangci-lint |
make test | go test ./... -race — unit, httptest, both godog suites, MCP evals, fitness tests | Go only (unit/BDD test doubles: the in-memory adapters never run in a binary) |
make coverage | make test with -coverpkg=./internal/domain/...,./internal/application/... and the 90 % gate | Go |
make bdd | go test ./... -run TestFeatures -v (the REST acceptance suite) | Go |
make arch-test | go test ./internal/architecture/... -v | Go |
make integration | go test -tags=integration ./... -race -count=1 | Docker (testcontainers boots Postgres / Kafka per suite; no DATABASE_URL, no compose) |
make contract | scripts/contract-test.sh | pip install 'schemathesis==4.28.0' |
make mutation | gremlins unleash ./internal/domain/stock | gremlins v0.6.0 |
make mutation-full | gremlins unleash ./internal/domain --workers 1 --timeout-coefficient 30 | gremlins v0.6.0 |
make vuln | govulncheck ./... | govulncheck |
make check | fmt-check vet build lint test | — |
make check-all | check + coverage arch-test bdd | — |
make check-fast | fmt-check vet arch-test + tests of packages changed vs HEAD | — (agent Stop hook) |
make guide-lint / make harness-test | scripts/harness/guide_lint.py / scripts/harness/test_hook.py | Python 3 |
Git hooks (lefthook.yml, after lefthook install): pre-commit runs
make fmt-check, make vet, make lint; pre-push runs make check.
Neither runs integration or mutation.
The layers
Unit and handler tests
Plain go test with the in-memory adapters (test doubles only; no binary links
them, ADR 0042) and fixed clocks: aggregates and
value objects in internal/domain/*, use cases in
internal/application/usecases, the HTTP handlers through httptest
(internal/adapters/inbound/http), Kafka consumers against fake readers,
publishers' encoding (including the events/testdata/log_publisher_golden.json
golden), and composition-root wiring in cmd/inventory/*_test.go and
cmd/mcp/*_test.go. CI enforces 90 % statement coverage over the domain and
application packages.
Acceptance (BDD)
features_test.go runs every features/*.feature with godog against a fresh
cmd/inventory router wired to the in-memory test doubles — a black-box test of
the REST API
(ADR 0007).
| Feature file | Scenario definitions |
|---|---|
bin_registration.feature | 7 |
bin_validation.feature | 1 |
classification_rules.feature | 4 |
container_rules.feature | 5 |
containers.feature | 14 |
cycle_count.feature | 3 |
cycle_count_edges.feature | 2 |
demand_ref.feature | 4 |
fulfillment_rules.feature | 10 |
held_stock.feature | 4 |
inbound_receipt.feature | 1 |
order_pick_completion.feature | 3 |
product_classification.feature | 1 |
receive.feature | 1 |
relocation_rules.feature | 23 |
reservation.feature | 4 |
reservation_expiry.feature | 4 |
reservation_lines.feature | 4 |
storage_rules.feature | 22 |
stow.feature | 3 |
stow_placement.feature | 5 |
transfer_allocation.feature | 10 |
transfer_receipt.feature | 9 |
transfer_scan_edges.feature | 13 |
transfer_stow.feature | 13 |
transfer_stow_rules.feature | 1 |
usable_inventory.feature | 1 |
| Total | 172 (249 executed) |
The *_rules.feature files pin rules documented in docs/ddd/ (use cases,
aggregate canvas, troubleshooting) one by one: relocation (#17-#20), storage
(#1-#6, #9-#11), fulfillment (#12, #13), classification (#8), containers and
transfer stow (#16). Step definitions for them are in features_rules_test.go
(registered from features_test.go; the other suites live in the sibling
features_*_test.go files). The BDD-only statement coverage over
./internal/... (go test . -run TestFeatures -count=1 -coverpkg=./internal/...)
is 64.7 %.
MCP evals
Three layers over cmd/mcp's server (ADR 0027),
all in internal/adapters/inbound/mcp:
- E1 schema and registry (
eval_governance_test.go): input schemas resolve and constrain, every parameter is described, the registry matchestestdata/tool_registry.golden(name, read-only, destructive), and tool names are unique againsttestdata/fleet_tool_snapshot.golden. - E2 wire conformance (
eval_conformance_test.go): initialize handshake, unknown tool / resource / prompt rejected, wrong-typed and extra arguments rejected, resource template and prompt discovery, session close. - E3 behaviour (
evalsuite_test.go):testdata/features/mcp_tools.feature(9 scenarios) through godog.
They run in make test and again, by name, in the evals-tests CI job.
Architecture fitness
internal/architecture (ADR 0006,
ADR 0029):
| Test | Guards |
|---|---|
TestHexagonalArchitecture | arch-go layering: domain imports nothing internal; application only domain; inbound and outbound adapters never import each other; nothing imports cmd; ports holds only interfaces; the analytics region is isolated. |
TestMCPAdapterDependencyRule | The MCP adapter depends only on the application and domain layers, and nothing else imports it (ADR 0008). |
TestNoAuthMiddlewareReintroduced | No auth middleware on REST or MCP (the fleet is unauthenticated). |
TestKafkaConsumerGroupNeverHardcodedInline | Consumer group ids are named constants or configuration. |
TestKafkaIntegrationTestsUseTestcontainers (+ detector test) | Kafka integration tests boot their own broker (checked per file). |
TestPostgresIntegrationTestsUseTestcontainers (+ detector test) | Postgres integration tests boot their own database (checked per package). |
TestEventCatalogueMatchesContract (+ detector test) | The event catalogue in code matches the messages declared in apis/asyncapi.yaml. |
TestCloudEventsOnly | No EVENT_ENVELOPE_MODE toggle anywhere, and a module that talks to Kafka imports the CloudEvents SDK. |
TestReplayConsumersSetCommitInterval | A kafka-go reader on a process-unique group (the facility cache's full replay) sets CommitInterval. |
TestDomainHasNoWireStructTags (+ detector test) | No json: / db: tags on domain types. |
TestRuntimeBinaryHasNoInMemoryAdapters (+ TestRuntimeBinarySensorBites, TestRuntimeBinarySensorCoversEveryCmd, runtime_no_memory_fitness_test.go) | No non-test file under cmd/** imports internal/adapters/outbound/memory: Postgres and Kafka are the only runtime (ADR 0042). The twins prove the sensor flags a bad fixture and that it covers every cmd/ directory. |
TestOutboxRelaysPassAttemptCap (+ TestOutboxRelayCapSensorFailsOnBadFixtures) | Every non-test NewOutboxRelay call under cmd/ passes WithMaxAttempts (ADR 0038), so one poison row cannot block the relay forever. |
TestMCPOptionalToolInputsCarryOmitempty (+ TestMCPOptionalToolInputsSensorFailsOnBadFixtures) | An MCP tool input field whose jsonschema description says "optional" carries omitempty, or the SDK advertises it as required and calls without it fail (gap fix D16). |
TestKafkaWritersSetRequiredAcks (+ TestKafkaWriterAcksSensorBites) | Every 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.) |
Integration (testcontainers)
44 *_integration_test.go files behind //go:build integration. Each suite
starts its own postgres and/or Kafka container
(internal/testsupport/kafkatc waits for the group coordinator before tests
run). Covered: every Postgres repository, migrations, optimistic concurrency,
the idempotency middleware (including lineNo), the outbox publisher and relay
(including the attempt cap: a poison row, then a good row that publishes, and
the re-arm SQL, outbox_relay_cap_integration_test.go),
the sweeper, pool limits, rehydration, the transfer, confirm-pick, inbound
receipt and product-master hand-overs at the use-case level, the analytics
store, the facility cache consumer, publisher partitioning, the MCP
Streamable-HTTP transport, the cmd/inventory housekeeping wiring,
TestRunOnRealPostgresAndKafka (boots run(ctx) on real Postgres and Kafka,
cmd/inventory/e2e_integration_test.go) and cmd/mcp outbox wiring. CI runs the whole tree
(go test -tags=integration ./... -race -count=1) with
TESTCONTAINERS_RYUK_DISABLED=true.
Contract
scripts/contract-test.sh builds cmd/inventory, starts it on
127.0.0.1:18080 (CONTRACT_PORT) against the Postgres named by DATABASE_URL
and the Kafka broker named by KAFKA_BROKERS (the script refuses to start
without them; CI provides a postgres:16 and a confluentinc/confluent-local
service container, locally start disposable ones as the script header shows),
waits for /readyz, and runs
st run apis/openapi.yaml with up to 100 examples per operation
(CONTRACT_MAX_EXAMPLES) and 4 workers, with the hooks in
scripts/contract_hooks.py (a fresh UUID Idempotency-Key per request) and
--generation-allow-x00 false (a NUL byte is answered with a client error
before any other middleware, internal/adapters/inbound/http/nul.go). Excluded
(--exclude-operation-id / --exclude-tag, scripts/contract-test.sh:137-140):
the Reports tag (served by cmd/inventory-reports) and the operations
stageTransferReceipt, stowTransferStock (a well-formed scan with no ledger
row is quarantined with 422 by design) and relocateStock (a well-formed body
with fromBin == toBin is refused with 422 same-bin), because Schemathesis'
positive-data-acceptance check cannot model "valid shape, refused by domain
state"; the unit, integration and BDD suites pin them instead. classifyProduct
left the spec at stage E, so no exclusion remains for it.
Mutation
gremlins v0.6.0 with .gremlins.yaml: 1 worker, timeout coefficient 30, and
thresholds efficacy 99 and mutant-coverage 99 (gremlins fails at or
below the threshold, so a single surviving mutant fails the run). The fast
subset ./internal/domain/stock blocks every PR (mutation-fast); the whole
./internal/domain runs weekly (mutation).
Frontend and chart
web/ (the inventory micro-frontend) has its own Vitest suite (npm test),
oxlint and tsc -b, run by the web job. The chart has two tests, both run
by the chart-tests CI job: charts/inventory-storage/tests/render_test.sh
(the API Deployment mounts the env ConfigMap with envFrom, tuned config.*
values reach it, the other workloads do not mount it) and
charts/inventory-storage/tests/test_service_selectors.py (each Service
selects exactly one Deployment). Run them locally with
bash charts/inventory-storage/tests/render_test.sh and
python3 charts/inventory-storage/tests/test_service_selectors.py.
CI jobs
.github/workflows/ci.yml runs on push and pull request to main and
develop, weekly (Monday 06:00 UTC) and on dispatch.
| Job | Runs | When |
|---|---|---|
lint | golangci-lint v2.13.1 | always |
guide-lint | guide_lint.py, repo_lint.py, test_hook.py, test_repo_lint.py | always |
complexity | golangci-lint with gocyclo,gocognit,cyclop,funlen,nestif; informational gocyclo > 10 report | always |
test | build, vet, then make coverage (go test ./... -race with the Makefile's coverage scope and 90 % gate) | always |
bdd | go test ./... -run TestFeatures -v | always |
contract | scripts/contract-test.sh | always |
evals-tests | go test ./internal/adapters/inbound/mcp/... -race -run '^TestEval|^TestMCPEvalSuite' -v | always |
integration | go test -tags=integration ./... -race -count=1 | always |
mutation-fast | gremlins unleash ./internal/domain/stock | always |
mutation | gremlins unleash ./internal/domain | schedule / dispatch only |
drift | deadcode, go mod tidy -diff, knip on web/, coverage-quality report | schedule / dispatch only |
api-lint | Spectral on apis/openapi.yaml and apis/asyncapi.yaml | always |
vuln | govulncheck v1.1.4 | always |
docs-api-drift | npm run clean-api-docs inventory && npm run gen-api-docs inventory, then git diff --exit-code -- docs/api-reference/rest | always |
helm-lint | ct lint --charts charts/inventory-storage | pull requests |
chart-tests | bash charts/inventory-storage/tests/render_test.sh (ConfigMap envFrom mount, config values) and python3 charts/inventory-storage/tests/test_service_selectors.py (with PyYAML pinned) | always |
arch-test | go test ./internal/architecture/... -v | always |
web | builds warehouse-ui-kit develop, then lint, tsc -b, test, build of web/ | always |
trivy-scan | image build + Trivy, blocking on fixable CRITICAL/HIGH | pull requests |
docker-publish | push, cosign sign, SBOM attest to ghcr.io/iqvo/inventory-storage | push to main |
release | next vX.Y.Z tag, Helm chart to oci://ghcr.io/iqvo, GitHub release | push to main |
.github/workflows/docs.yml builds this site (npm ci && npm run build in
docs/) on pull requests that touch docs/** or apis/**, and builds and
deploys it to GitHub Pages on push to main.
Running a single layer locally
go test ./internal/domain/... -race # one package
go test -run TestFeatures -v . # REST acceptance suite only
go test -tags=integration ./internal/adapters/outbound/postgres/... -race -count=1
go test ./internal/adapters/inbound/mcp/... -run '^TestEval|^TestMCPEvalSuite' -v
CONTRACT_MAX_EXAMPLES=20 ./scripts/contract-test.sh