Testing
The full guide (what each layer proves, how to add a test, and performance monitoring) is the How we test page, where the explainers walk through it: /test/.
| Layer | Project | Proves |
|---|---|---|
| Unit | tests/Integrations.UnitTests | Domain rules, services, AvaTax mapping |
| Architecture | .../Architecture/LayeringTests.cs | The dependency rules in the architecture overview |
| Contract | .../ContractTests | Messages and the HTTP surface don't change by accident (approval snapshots) |
| Docs | .../Documentation | Every message has an event page with the right fields. Every endpoint has a summary. |
| Integration | tests/Integrations.IntegrationTests | Real Postgres, HTTP pipeline, messaging, real AvaTax SDK against WireMock, performance budgets |
| End-to-end | tests/e2e (Playwright) | Browser flows, accessibility (axe), phone layout, docs pages |
| Mutation | build/stryker/*.json (Stryker.NET, nightly) | The unit tests notice a flipped comparison or a dropped statement in Domain and Application |
| Load | tests/load/smoke.js (k6) | Latency, errors and response checks under load against a deployment; -e WRITE=true also creates, commits and voids documents (staging) |
CI runs unit, integration and end-to-end tests on every push, with a coverage gate (build/coverage-gate.py): line and
branch floors per project, about two points under the current figures, and a failure when a project is missing from
the reports. Raise the floors when coverage goes up.
Writing tests
- Test data: start from
TestData.Invoice(id)and theTestData.Austin/TestData.Columbusjob sites (tests/Shared/TestData.cs, linked into both test projects) and vary them withwith { ... }. Don't copy a helper into another class. - Time: business time is a
FakeTimeProvider(TaxTestHost.Time,IntegrationsApiFactory.Time). Caches and throttles (tax-code mappings, on-demand FX refresh) run on the business clock, soTime.Advance(...)expires them. - Outside a request: a test that calls a service, consumer or job directly runs it under
CallerScope.Begin(new SystemCallerContext("test")), the way the job runner does; with no caller, entity access is denied. - Bug fixes: write the test first and watch it fail without the fix.
- AvaTax:
AvaTaxProviderTestsdrives each adapter against WireMock (paging, void of a document AvaTax never received, certificates, and each failure: 401, 429, 5xx, timeout, unreadable JSON, data errors). Add the case there when AvaTax surprises us. - Schema:
MigrationsTestsfails when the EF model changes without a migration.
Mutation testing
dotnet tool restore
cd src/Integrations.Domain && dotnet stryker --config-file ../../build/stryker/domain.json
The HTML report lists every surviving mutant (a change no test noticed). Kill them with a test, or accept them when
they don't matter (e.g. an error message's wording). The nightly mutation workflow fails below each layer's break
threshold; raise the thresholds as the scores go up.