Skip to main content

Testing

The pyramid below is what is on develop. Go is 1.27.3 (go.mod); the pinned tools are golangci-lint v2.14.0 and gremlins v0.6.0 (Makefile). Nothing needs a database for make check; only make integration needs Docker.

Layers​

LayerWhereWhat it provesNeeds
Domain unit testsinternal/domain/cart/*_test.go (lines, delivery, selection, lifecycle, restore), internal/domain/estimate, internal/domain/sharedthe aggregate invariants: quantity 1 to 99, at most 100 lines, merge rules, quote and selection rules, the 30-day idle rule, the estimate mathsnothing
Application testsinternal/application/usecases/*_test.go (commands, queries, delivery, consume, policies, cart_metrics_test.go)use cases over the in-memory test doubles: one unit of work per command, events raised and appended to the outbox, inbox idempotency, the business counternothing
Adapter unit testsinternal/adapters/**/**_test.goHTTP routes, problem documents and idempotency with httptest (internal/adapters/inbound/http: the replay-class tests of the fleet harness template over the in-memory store, idempotency_replay_classes_test.go + its wiring, keep every catalogue entry classified and every class replaying or re-executing as declared, ADR 0011), the consumer run loop, retries, dead letters and tracing (inbound/kafka), the scheduler, the A2A skills, Agent Card and REST parity (inbound/a2a), the relay (outbound/outbox), the CloudEvents encoder against golden files (outbound/kafka/testdata/*.golden.json), the delivery-promise client (outbound/deliverypromise), telemetry and log correlation, the boot retrynothing
Composition-root testscmd/api/main_test.go, cmd/api/telemetry_test.go, cmd/a2a/*_test.goboot refusals, environment parsing, shutdown order, the router, one request yielding a server span and a log line that carry the same trace_idnothing
Godog featuresfeatures/*.feature (17 files, 155 Scenario and Scenario Outline headings; 219 scenarios run once the Examples rows are expanded), steps in internal/bddthe business behaviour through the real HTTP router and use cases, wired to the in-memory doubles (TestFeatures, strict mode). Six files are the original acceptance set (api_idempotency, cart_lines, delivery, estimate, lifecycle, paged_list_strictness); eleven *_rules.feature files pin the documented rules: line_rules, closed_cart_rules, delivery_rules, requote_rules, merge_rules, estimate_rules, policy_rules, read_model_rules, idempotency_rules, list_rules, readiness_rulesnothing
Integration8 files tagged //go:build integration: cmd/api/e2e_integration_test.go, cmd/api/e2e_flow_integration_test.go, cmd/a2a/postgres_integration_test.go, internal/adapters/outbound/postgres/{main,migrate,repositories,outbox_trace}_integration_test.go, internal/adapters/outbound/outbox/main_integration_test.gothe real run entry points on a real Postgres and Kafka, the embedded migration, the repositories, the outbox with trace headers, the relayDocker; every test boots its own containers through internal/testing/pgtest and internal/testing/kafkatest
Contractinternal/adapters/outbound/repocontract (one suite run against the in-memory store and against Postgres), deliverypromise/spec_test.go and testdata/delivery-promise.openapi.yaml (the consumed delivery-promise route), inbound/a2a/parity_test.go (A2A answers carry exactly the properties of the apis/openapi.yaml schemas), the encoder golden files, internal/architecture/catalogue_fitness_test.go (every type in apis/asyncapi.yaml is in the CloudEvents ADR)the ports behave the same on every adapter and the wire shapes do not driftnothing, except the Postgres run of the repository contract (integration)
Architecture fitnessinternal/architecture/*_test.go (13 files)see belownothing
Mutation.gremlins.yaml, make mutation, make mutation-fullthe domain tests assert, not just execute. Thresholds: efficacy 98, mutant coverage 98 (plain numbers; the residuals are in MUTATION.md), one worker, timeout coefficient 30gremlins
Chart testscharts/shopping-cart/tests/render_test.sh (needs helm), test_service_selectors.py (needs PyYAML)the chart refuses to render without the mandatory values, renders every variable the binaries read, hardens the pod, sizes the grace period against the shutdown bounds, keeps the A2A agent read-only and off by default, every Service selects one Deploymenthelm, Python 3

Architecture fitness tests​

All are in internal/architecture and run with make arch-test:

TestRule
TestHexagonalArchitecturesix rules: internal/domain imports only itself; internal/application only domain and application; inbound adapters never import outbound ones and the reverse; nothing under internal imports cmd; the ports package holds interfaces only
TestRuntimeBinaryHasNoInMemoryAdapters (and ...SensorBites)cmd/** never imports the in-memory adapter: the runtime is Postgres and Kafka only
TestA2AAdapterDependencyRule, TestA2ASurfaceIsReadOnly (and TestA2ASensorBites)the A2A adapter depends only on application and domain, calls no other context and cannot write
TestNoAuthMiddlewareReintroducedno auth middleware exists in the REST adapter (fleet decision)
TestKafkaConsumerGroupNeverHardcodedInlineconsumer group ids come from the environment, never a literal
TestCloudEventsOnly, TestNoEventEnvelopeToggleOrFlatEnvelopeevery Kafka message is a CloudEvents 1.0 envelope, with no flat-envelope toggle
TestKafkaWritersSetRequiredAcks, TestKafkaWriterTopicNotSetTwice, TestDeadLetterCallsGuardCancellation, TestReplayConsumersSetCommitIntervalwriter and consumer settings that would silently lose or duplicate messages
TestOutboxRelaysPassAttemptCapthe relay is built with an attempt cap so a poison row cannot block it
TestEventCatalogueMatchesContractevery type apis/asyncapi.yaml declares is listed in the CloudEvents ADR
TestPostgresIntegrationTestsUseTestcontainers, TestKafkaIntegrationTestsUseTestcontainersintegration tests boot their own containers, with no skip gate
TestNoGoFilesAtRepoRootno Go file at the repository root
TestMCPAdapterDependencyRule, TestMCPOptionalToolInputsCarryOmitemptythe MCP adapter (cmd/mcp, ADR 0009) imports only the application and domain layers, and an optional tool input carries omitempty
TestEveryMCPToolDeclaresAuthority, TestMCPWriteToolsAreAtLeastL3, TestA2ASkillsDeclareAuthority, TestMCPServerOffersResourceAndPrompt and their ...SensorBites companionsevery MCP tool and A2A skill declares an authority level, a write tool is at least L3, and the MCP surface has a resource and a prompt

Each sensor that scans source has a companion test (...SensorBites, ...FailsOnBadFixtures) proving it fails on a bad fixture.

Make targets​

TargetRunsNotes
make helplists the targetsdefault
make buildgo build ./...
make vetgo vet ./...
make fmt, make fmt-checkgofmt -w . / fail if gofmt -l . is non-empty
make lintgolangci-lint run --allow-parallel-runners ./...pinned v2.14.0; config .golangci.yml includes complexity limits
make testgo test ./... -raceunit, httptest and godog; no database
make coveragetests with -race and -coverpkg=./internal/domain/...,./internal/application/..., then the 90% gatethe only definition of the coverage scope
make bddgo test ./... -run TestFeatures -vgodog features
make arch-testgo test ./internal/architecture/... -vfitness tests
make integrationgo test -tags=integration ./... -race -count=1Docker; not in check
make mutationgremlins over each ./internal/domain/*/ package in turnthe fast, blocking gate
make mutation-fullgremlins over ./internal/domain with --workers 1 --timeout-coefficient 30the scheduled, exhaustive run
make vulngovulncheck ./...
make checkfmt-check vet build lint testthe pre-push bundle (lefthook)
make check-allcheck coverage arch-test bddrun before opening a PR
make check-fastfmt-check vet arch-test plus the tests of the packages changed against HEADthe agent stop hook
make guide-lint, make harness-testlints the agent guides; tests the agent hooks

Chart tests, run from the repository root:

bash charts/shopping-cart/tests/render_test.sh
python3 charts/shopping-cart/tests/test_service_selectors.py

Documentation site, from docs/: npm ci, npx tsc --noEmit -p ., npm run build (fails on a broken link or an MDX error).

CI jobs​

.github/workflows/ci.yml runs on pushes and pull requests to main and develop, weekly on Monday 06:00 UTC for the mutation job, and on demand.

JobWhat it runsBlocking
lintgolangci-lint v2.14.0yes
guide-lintscripts/harness/guide_lint.py, test_hook.pyadvisory (continue-on-error)
complexitygolangci-lint with only gocyclo, gocognit, cyclop, funlen, nestif, plus an informational gocyclo reportyes
testgo build, go vet, then make coverage (90% gate), uploads coverage.outyes
bddgo test ./... -run TestFeatures -vyes
integrationgo test -tags=integration ./... -race -count=1yes
mutation-fastgremlins on every internal/domain/*/ packageyes
mutationgremlins on ./internal/domain; schedule or manual only; opens or closes a harness:red issue on a scheduled failureschedule
driftdeadcode -test ./..., go mod tidy -diff and scripts/coverage-quality.py (high-coverage functions with a surviving mutant) written to the job summary; harness:red issue on a scheduled failureno (advisory, schedule and dispatch only)
api-lintSpectral on apis/openapi.yaml and apis/asyncapi.yaml with --fail-severity=warnyes
vulngovulncheck ./...yes
docs-api-driftnpm ci, npm run clean-api-docs and npm run gen-api-docs in docs/, then fails when docs/docs/api-reference/rest differs from what is committedyes
helm-lintct lint and helm lint with both ci/*-values.yaml; pull requests onlyyes
chart-testsevery charts/shopping-cart/tests/*.sh and test_*.py; a printed SKIP fails the jobyes
arch-testgo test ./internal/architecture/... -vyes
trivy-scanbuilds the image locally (not pushed), uploads a Trivy SARIF report (CRITICAL/HIGH/MEDIUM) and fails on a CRITICAL or HIGH OS/library finding that has a fixyes, pull requests only
docker-publishbuilds and pushes ghcr.io/iqvo/shopping-cart, signs with cosign, attaches an SBOM; push to main after the gates abovemain only
releasetags vX.Y.Z, retags the image, packages and pushes the Helm chart to oci://ghcr.io/iqvo, creates the GitHub releasemain only

Other workflows: docs.yml builds this site on every pull request touching docs/** or apis/** and deploys to GitHub Pages from main; codeql.yml runs code scanning; ai-review.yml runs the AI review.

Notes​

  • .gremlins.yaml and the Makefile header mention a drift job and a scaffold script; ci.yml has no drift job on this branch.
  • The godog features and the application tests use internal/adapters/outbound/memory. It is test-only: TestRuntimeBinaryHasNoInMemoryAdapters keeps it out of cmd/**.
  • A new consumed or published event type needs, in the same change: the apis/asyncapi.yaml entry, the ADR 0004 catalogue entry (TestEventCatalogueMatchesContract), and for a published type a golden file in internal/adapters/outbound/kafka/testdata.