Skip to main content

Testing

All commands run from the repo root. Docker is needed only for make integration. Nothing here was run while writing the page; counts come from reading the tree.

The pyramid​

LayerWhereWhat it provesNeeds
Unit (domain)internal/domain/{shared,trailer,yardcheck,yardmove,yardpolicy,yardvisit}/*_test.goaggregate invariants and state machines, no I/OGo
Unit (application)internal/application/usecases/*_test.go (7 files)every use case over in-memory portsGo
Adapter unit testsinternal/adapters/inbound/http (handlers, idempotency, readiness), inbound/mcp (tools, idempotency, attribution, governance), inbound/kafka (consumers, retry, dead-letter), outbound/kafka (encoder golden tests, relay sink, health), kafka/cloudevents, cmd/api, cmd/mcp, cmd/relayeach adapter against fakes/httptestGo
Godog featuresfeatures/*.feature, runner internal/bdd/bdd_test.go (TestFeatures)the REST adapter and use cases end to end on the in-memory storeGo
Repository contractinternal/testing/repocontractone behavioural suite every store must pass (visits, trailers, moves, checks, policies, locations, appointments, closures, ASNs, receipts, the unit of work, locks)Go (memory), Docker (Postgres)
Integration*_integration_test.go, build tag integrationreal Postgres and Kafka through testcontainers: the Postgres repositories (contract suite), the outbox relay, the Kafka consumers of the three topics, the analytics store (OLTP and KPI), cmd/api, cmd/mcp, cmd/relay entry pointsDocker
Mutation.gremlins.yaml, make mutationtests assert, not merely execute, on internal/domain/*gremlins v0.6.0
Architecture fitnessinternal/architecture/*_test.gostructural rules (below)Go
Spec/code parity (problem types)internal/adapters/inbound/http/spec_problems_test.goevery problem type the REST adapter can answer is declared in apis/openapi.yaml, and every problem the spec shows is one the adapter writes, with its status and titleGo
Contract lintspectral on apis/openapi.yaml and apis/asyncapi.yaml (CI api-lint)the specs follow the fleet rulesetsspectral

There are no consumer-driven contract tests against sibling services: yard-management calls no sibling (see Integration). The consumed messages are covered by the Kafka consumer tests under internal/adapters/inbound/kafka, and TestEventCatalogueMatchesContract ties the produced catalogue to apis/asyncapi.yaml. On the REST side TestTheSpecDeclaresEveryProblemTypeTheAdapterAnswers ties the problem types the adapter can answer to apis/openapi.yaml.

Godog features​

Sixteen files, 239 Scenario and Scenario Outline definitions (git grep -c -E "^[[:space:]]*Scenario" -- 'features/*.feature'); with the Examples rows expanded the runner executes 340 scenarios (340 scenarios (340 passed) from go test ./internal/bdd -run TestFeatures -count=1 -v). They are tagged @bdd and run the REST handlers on the in-memory store (internal/adapters/outbound/memory) behind the real HTTP handlers (httptest), with the events the use cases publish captured for the the event "X" was published steps:

FeatureDefinitions / executedCovers
audit_rules.feature12 / 17the documented rules of the yard policy (defaults, validation, replace not merge), the yard check (one open per site, one observation per location, MISSING / UNEXPECTED / WRONG_LOCATION) and the yard board
checkout.feature7 / 7a visit leaves only with released trailers (no open move; parked, or docked with door work done); seal on a loaded pickup; a visit checks out once
compliance_inspections.feature37 / 55built-in and custom checklist templates (versions never change), an inspection from open to PASSED or FAILED, the hold a failure places, and the site policy gates before a door move, loading and check-out (ADR 0015)
dock_safety_interlock.feature16 / 18securing before door work and release before leaving the door, trailer-still-secured (ADR 0013)
drop.feature3 / 3drop trailer: hold, door, work, clear door, tractor leaves
floor_client.feature12 / 17what the gate kiosk, dock tablet and hostler phone rely on: optional trailers, deviation note, filters, no lease renewal, sweeps without key, idempotent replay, ETag of the policy, report shape before analytics
gate_rules.feature24 / 35the documented gate rules: carrier name and SCAC, one open visit per plate, the appointment copy (appointment-required, unknown-appointment, a cancelled booking), DirectOnCheckIn and the tolerance boundary, the all-or-nothing check-out and the seal rule
hazmat_reefer_placement.feature19 / 40hazmat and reefer placement by spot kind (ADR 0014)
lease.feature7 / 7claim leases, the expiry sweep, lease ownership, one move per hostler, claim order (lowest band, earliest due)
live_unload.feature4 / 4live unload from gate in to gate out, receipt-close auto-completes the unload, ASNs carried by the trailer
move_rules.feature35 / 53the documented rules of RequestMove, ClaimNextMove, CompleteMove and CancelMove, the lease and ReturnToOrigin, ArriveAt, CallToDoor and NoShowFreesHolding
occupancy.feature11 / 14one trailer per spot or door, reservations, one open move per trailer, races end in 409, closed doors, flow mismatch, holds
rejection.feature9 / 9gate turn-away, appointment required, seal mismatch under FLAG and REJECT, one open visit per plate, unknown appointment
standard_identifiers.feature19 / 29ISO 6346 unit numbers, seal class and seal state vocabulary (ADR 0012)
standard_vocabulary.feature8 / 12the optional X12 214 / CBV fields on the published facts (gate in and out, departure, inspection outcome, hold reason), the facts that carry none are byte-for-byte the legacy payload, and an old consumer still decodes (ADR 0018; the MCP attribution case is attribution_standards_internal_test.go)
trailer_rules.feature16 / 20door work order, holds and their release, the trailer version (ETag), AutoCompleteUnload, the dwell sweep

Steps are in internal/bdd/steps_*_test.go. Run one feature with go test ./internal/bdd -run TestFeatures -v.

Architecture fitness tests​

make arch-test (go test ./internal/architecture/... -v). Each sensor also has a "bites" test proving it fails on a bad fixture.

TestRule
TestHexagonalArchitecturedomain imports nothing outward; application imports domain and ports only; adapters never import each other
TestEventCatalogueMatchesContractthe events the code publishes equal the catalogue of apis/asyncapi.yaml
TestCloudEventsOnly, TestNoEventEnvelopeToggleOrFlatEnvelopeevery message is a CloudEvents 1.0 envelope, no flat or toggled envelope
TestReplayConsumersSetCommitIntervalconsumer commit settings
TestKafkaConsumerGroupNeverHardcodedInlineconsumer groups come from the environment
TestKafkaIntegrationTestsUseTestcontainers, TestPostgresIntegrationTestsUseTestcontainersno DATABASE_URL-gated or skipped integration tests
TestDeadLetterCallsGuardCancellationthe dead-letter path checks ctx.Err() so shutdown never dead-letters
TestKafkaWritersSetRequiredAcks, TestKafkaWriterTopicNotSetTwiceacks=all; a writer has its topic on the writer or the message, never both
TestOutboxRelaysPassAttemptCapthe composition root passes WithMaxAttempts
TestRuntimeBinaryHasNoInMemoryAdapterscmd/** never imports the memory package
TestNoGoFilesAtRepoRootno .go at the repo root
TestMCPAdapterDependencyRule, TestEveryMCPToolDeclaresAuthority, TestMCPWriteToolsAreAtLeastL3, TestMCPServerOffersResourceAndPrompt, TestMCPOptionalToolInputsCarryOmitemptyMCP adapter layering, authority annotations, optional inputs
TestNoAuthMiddlewareReintroducedno auth middleware reappears (fleet decision)
TestEveryPublishedTypeOfTheContractHasAStandardsDecision, TestTheContractDeclaresTheStandardFieldsOnTheRightSchemasAsOptional, TestADR0018ListsTheMappingthe standard-vocabulary table (internal/domain/standards) decides every published type, the contract declares its optional fields exactly where it maps them, and ADR 0018 lists every event, variant, code and source

Mutation testing​

.gremlins.yaml (gremlins v0.6.0, one worker, timeout coefficient 30) sets efficacy 90 and mutant coverage 65 as a blocking floor, measured per domain package. make mutation runs gremlins once per internal/domain/* package (a new package is picked up by the wildcard); make mutation-full runs the exhaustive pass on ./internal/domain. The file records the last measurement per package (shared, trailer, yardmove, yardvisit at 100 % efficacy; yardcheck 94.74 %, yardpolicy 100 %).

Make targets​

TargetRuns
make checkfmt-check vet build lint test (fast pre-commit; lefthook runs it)
make check-allcheck + coverage + arch-test + bdd (before pushing)
make testgo test ./... -race (unit, handler tests, godog)
make coveragesame with -coverpkg=./internal/domain/...,./internal/application/..., fails below 90 %
make integrationgo test -tags=integration ./... -race -count=1 (Docker; not in check)
make bddgo test ./... -run TestFeatures -v
make arch-testthe fitness tests
make mutation / make mutation-fullgremlins fast subset / exhaustive
make vulngovulncheck ./...
make lint, make vet, make fmt, make fmt-check, make buildas named
make check-fast, make guide-lint, make harness-testagent-harness helpers (scripts/harness)

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

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

JobRunsWhen
lintgolangci-lintalways
guide-lintscripts/harness/guide_lint.py, test_hook.pyalways
complexitygocyclo report (gate 15)always
file-lengthfile-length gate on touched Go filesalways
testbuild, vet, make coveragealways
bddgo test ./... -run TestFeatures -valways
integrationgo test -tags=integration ./... -race -count=1always
mutation-fastgremlins per domain packagealways
mutationexhaustive gremlins; opens/closes a harness:red issueschedule, dispatch
driftdead code, go mod tidy -diff, coverage-qualityschedule, dispatch
api-lintspectral on the OpenAPI and AsyncAPI specsalways
vulngovulncheckalways
arch-testgo test ./internal/architecture/... -valways
helm-lintct lint and chart wiring testspull requests
chart-testscharts/yard-management/tests/*.sh and test_*.pyalways
trivy-scanbuilds the image, Trivy SARIF + blocking gate (CRITICAL/HIGH with a fix)pull requests
docker-publishbuild, push to ghcr.io/iqvo, cosign, SBOM; needs lint, complexity, test, bdd, integration, mutation-fast, vuln, api-lint, arch-testpush to main
releaseversion tag, chart package, GitHub release; needs docker-publishpush to main

The docs site has its own workflow, .github/workflows/docs.yml: it builds on pull requests touching docs/** or apis/** and deploys to GitHub Pages on push to main. There is no docs-api-drift job in ci.yml.