Testing
The pyramid as it stands on develop. Everything except make integration runs without Docker, Postgres or Kafka.
| Layer | Where | How many | Runs with |
|---|---|---|---|
| Unit (domain, application, adapters) | internal/domain/**, internal/application/**, internal/adapters/**, internal/bootretry, cmd/*/main_test.go | about 89 _test.go files, 12 of them *_integration_test.go | make test |
| HTTP handler tests (no database) | internal/adapters/inbound/http/*_test.go | readiness, NUL rejection, idempotency capture, scorecard, telemetry, handlers | make test |
| BDD acceptance (godog) | features/*.feature | 13 feature files, 168 scenario definitions, 222 executed | make bdd (also part of make test) |
| Integration (testcontainers) | files tagged integration: cmd/api/e2e_integration_test.go, cmd/mcp, cmd/a2a, internal/adapters/outbound/{postgres,outbox,kafka}, internal/adapters/inbound/kafka | 12 *_integration_test.go files | make integration |
| Contract | event catalogue vs apis/asyncapi.yaml, MCP tool registry golden file, CloudEvents encoder/decoder, Spectral lint of both specs | see below | make arch-test, make test, CI api-lint |
| Mutation | internal/domain/** with gremlins | thresholds in .gremlins.yaml | make mutation, make mutation-full |
| Architecture fitness | internal/architecture/ | 12 test files, 31 Test* functions | make arch-test |
Unit and use-case tests
The domain packages (inboundplan, inboundshipment, seller, scorecard, network, shared, shared/gs1) have
table tests for every invariant; internal/application/usecases has flow_test.go (a shipment from onboarding to
receipt on in-memory test doubles), consumers_test.go, scorecard_test.go and shipment_metrics_test.go. The
in-memory store under internal/adapters/outbound/memory exists for tests only: a fitness test
(TestRuntimeBinaryHasNoInMemoryAdapters) fails if any cmd/** binary imports it.
make coverage runs the whole suite with the race detector and enforces a 90 % gate over
./internal/domain/... and ./internal/application/... (COVERAGE_PKGS and COVERAGE_THRESHOLD in the Makefile;
CI runs the same target, so the scope cannot drift).
godog features
Definitions are Scenario and Scenario Outline lines (git grep -c -E "^[[:space:]]*Scenario" -- features, an
Outline counts once); executed adds one run per Examples row and is the N scenarios line of make bdd. No scenario
is tagged @known-bug any more (see below).
| File | Definitions | Executed |
|---|---|---|
features/sellers.feature | 9 | 9 |
features/inbound_plans.feature | 9 | 9 |
features/shipments_and_labels.feature | 13 | 13 |
features/receipts.feature | 6 | 6 |
features/scorecard.feature | 8 | 8 |
features/node_limits.feature | 2 | 2 |
features/seller_account_rules.feature | 14 | 21 |
features/plan_rules.feature | 16 | 30 |
features/carton_rules.feature | 29 | 47 |
features/shipment_lifecycle_rules.feature | 15 | 16 |
features/receipt_rules.feature | 28 | 32 |
features/read_model_rules.feature | 8 | 8 |
features/scorecard_rules.feature | 11 | 21 |
| Total | 168 | 222 |
The first six files are the original suite, written from the OpenAPI contract. The *_rules files pin the documented
rules, invariants, caps, state edges and failure modes (seller account, plan lines and GTINs, carton and SSCC rules,
shipment lifecycle, receipt discrepancies and the ADR 0014 received lines, the node-topology and packaging read models,
and the scorecard thresholds at their edges).
Tags: BDD_TAGS selects scenarios (default ~@known-bug). @known-bug marks a scenario that states a documented rule
the code does not meet yet; BDD_TAGS=@known-bug go test ./features -run TestFeatures runs it and it fails until the
defect is fixed. @slow marks the 1000-carton scenario so mutation runs can skip it. The runner is Strict, so an
undefined step fails the run. The step table also has two placeholders, {shipment:N} and {repeat:c:N}.
The steps (features/steps_test.go, features/features_test.go) drive the real use cases and the real REST router over
in-memory adapters, and feed the consumers with CloudEvents built from the producers' contracts (node-topology,
offer-availability, vendor-connectivity). Run them alone with make bdd (go test ./... -run TestFeatures -v).
Integration tests
make integration runs go test -tags=integration ./... -race -count=1. It needs only Docker: every test boots its
own Postgres and Kafka with testcontainers, so there is no DATABASE_URL, no docker compose and no skip gate. Two
fitness tests enforce this (TestPostgresIntegrationTestsUseTestcontainers, TestKafkaIntegrationTestsUseTestcontainers).
cmd/api/e2e_integration_test.gostarts the realrunentry point against the containers and walks the REST API, the four consumers and the relay end to end (the sourcing consumer: a merged release landsdemand_heat_linesrows, a replayed event id is a no-op, a cancel removes the rows).cmd/mcpandcmd/a2ahave their ownmain_integration_test.go.internal/adapters/outbound/postgrescovers the repositories, the scorecard tables, and that an outbox row written under a span stores itstraceparent.internal/adapters/outbound/outboxcovers the relay and the attempt cap;outbound/kafkathe sink and writers;inbound/kafkathe consumers and dead-lettering.
Contract tests
TestEventCatalogueMatchesContract(internal/architecture/catalogue_fitness_test.go, a fleet-managed file) checks that everycom.warehouse.(wms|wes).<service>...orcom.retailnetwork.<domain>.<service>...type thatapis/asyncapi.yamldeclares for this module appears in the ADR catalogue. seller-inbound's types arecom.retailnetwork.partner.seller-inbound...; its ten published types are checked against ADR 0004, and the types it only consumes (other services' segments) are not required there.TestEventCatalogueDetectorpins both type shapes. A new event still changes the domain struct,apis/asyncapi.yamland the ADR 0004type:line in one commit (CLAUDE.md); the test now fails the build if the ADR line is missing.TestToolRegistryGoldenandTestToolSurface(internal/adapters/inbound/mcp/governance_test.go) pin the MCP tools tointernal/adapters/inbound/mcp/testdata/tool_registry.golden.json; refresh it withgo test ./internal/adapters/inbound/mcp -updateand review the diff. The same file checks that no tool name is a write verb.internal/adapters/kafka/cloudevents/cloudevents_test.goandinternal/adapters/outbound/kafka/encoder_test.gopin the CloudEvents envelope.- CI
api-lintruns Spectral onapis/openapi.yaml(.spectral.yaml) andapis/asyncapi.yaml(.spectral.asyncapi.yaml) with--fail-severity=warn.
Mutation testing
.gremlins.yaml sets one worker, timeout coefficient 30, and thresholds efficacy 99 and mutant-coverage 99.
The file records the last measurement: every domain package except inboundshipment at 100 %; inboundshipment at
99.23 % with one equivalent surviving mutant (receipt.go:195, the receipt normalisation already drops zero-quantity
items). make mutation runs gremlins on internal/domain/inboundshipment (the fast subset); make mutation-full on all of internal/domain.
gremlins is pinned to v0.6.0.
Architecture fitness tests
make arch-test runs go test ./internal/architecture/... -v. Each rule has a "sensor bites" companion that proves the
rule fails on a bad fixture.
| Rule | Test |
|---|---|
Hexagonal dependency direction (domain imports nothing outward, application only domain, adapters do not import each other) | TestHexagonalArchitecture |
| MCP and A2A adapters are read-only and import no REST adapter or outbound client | TestMCPAdapterDependencyRule, TestA2AAdapterDependencyRule, TestA2AAgentIsReadOnlyAndHasNoOutboundClient |
| No authentication middleware reintroduced | TestNoAuthMiddlewareReintroduced |
| Runtime binaries never import the in-memory adapters | TestRuntimeBinaryHasNoInMemoryAdapters |
| No Go file at the repository root | TestNoGoFilesAtRepoRoot |
| CloudEvents only, no flat envelope or toggle; replay consumers set a commit interval | TestNoEventEnvelopeToggleOrFlatEnvelope, TestCloudEventsOnly, TestReplayConsumersSetCommitInterval |
Event catalogue test (every own com.warehouse.(wms|wes) or com.retailnetwork type in apis/asyncapi.yaml is in ADR 0004) | TestEventCatalogueMatchesContract |
| Consumer group ids come from configuration, never a literal | TestKafkaConsumerGroupNeverHardcodedInline |
Kafka writers set RequiredAcks; a writer and its message never both set a topic; dead-letter calls guard cancellation | TestKafkaWritersSetRequiredAcks, TestKafkaWriterTopicNotSetTwice, TestDeadLetterCallsGuardCancellation |
| Every outbox relay passes the attempt cap | TestOutboxRelaysPassAttemptCap |
MCP optional inputs carry omitempty | TestMCPOptionalToolInputsCarryOmitempty |
| Integration tests use testcontainers | TestPostgresIntegrationTestsUseTestcontainers, TestKafkaIntegrationTestsUseTestcontainers |
Known discrepancy: internal/architecture/architecture_test.go:23 sets modulePath = "github.com/IQVO/seller-inbound"
while go.mod declares module github.com/claudioed/seller-inbound. Whether the arch-go rules of
TestHexagonalArchitecture resolve packages under the go.mod path was not verified for this page.
Make targets
| Target | What it runs |
|---|---|
make build / vet / fmt / fmt-check | go build ./..., go vet ./..., gofmt -w ., the gofmt check |
make lint | golangci-lint run --allow-parallel-runners ./... (pinned v2.14.0) |
make test | go test ./... -race |
make coverage | tests plus the 90 % gate |
make bdd | go test ./... -run TestFeatures -v |
make arch-test | the fitness tests |
make integration | testcontainers suite (Docker) |
make mutation / make mutation-full | gremlins |
make vuln | govulncheck ./... |
make check | fmt-check vet build lint test; the lefthook pre-push hook runs it |
make check-all | check plus coverage arch-test bdd |
make check-fast, make guide-lint, make harness-test | agent-harness helpers (changed packages, guide linter, hook tests) |
CI jobs (.github/workflows/ci.yml)
Triggers: push and pull request on main and develop, a weekly Monday schedule, and manual dispatch.
| Job | Runs | Gate |
|---|---|---|
lint | golangci-lint v2.14.0 | blocking |
guide-lint | agent-guide sensor and hook tests | advisory (continue-on-error) |
complexity | gocyclo, gocognit, cyclop, funlen, nestif plus an informational gocyclo report | blocking |
file-length | revive file-length-limit (at most 300 code lines per production Go file, .golangci.yml) | blocking on pull requests into develop for the Go files the PR adds or touches; an informational report of the whole backlog on push, schedule and release PRs |
test | build, vet, make coverage | blocking |
bdd | go test ./... -run TestFeatures -v | blocking |
integration | go test -tags=integration ./... -race -count=1 | blocking |
mutation-fast | gremlins on every package under internal/domain | blocking |
mutation, drift | exhaustive mutation, deadcode, go mod tidy -diff, knip, coverage-quality | scheduled and manual only; open a harness:red issue on a scheduled failure |
api-lint | Spectral on both specs | blocking |
vuln | govulncheck | blocking |
helm-lint | ct lint and the Service selector test | pull requests only |
chart-tests | every charts/seller-inbound/tests/*.sh and test_*.py | blocking |
arch-test | fitness tests | blocking |
web | the Module Federation remote: lint, tsc -b, vitest, build | blocking |
docker-publish, release | image, cosign signature, SBOM, Helm chart, tag | push to main only, after the jobs above |
docs.yml builds this site on pull requests and deploys it on a push to main. The CI has no trivy scan and no
generated-docs drift job.