Skip to main content

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/.

LayerProjectProves
Unittests/Integrations.UnitTestsDomain rules, services, AvaTax mapping
Architecture.../Architecture/LayeringTests.csThe dependency rules in the architecture overview
Contract.../ContractTestsMessages and the HTTP surface don't change by accident (approval snapshots)
Docs.../DocumentationEvery message has an event page with the right fields. Every endpoint has a summary.
Integrationtests/Integrations.IntegrationTestsReal Postgres, HTTP pipeline, messaging, real AvaTax SDK against WireMock, performance budgets
End-to-endtests/e2e (Playwright)Browser flows, accessibility (axe), phone layout, docs pages
Mutationbuild/stryker/*.json (Stryker.NET, nightly)The unit tests notice a flipped comparison or a dropped statement in Domain and Application
Loadtests/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 the TestData.Austin / TestData.Columbus job sites (tests/Shared/TestData.cs, linked into both test projects) and vary them with with { ... }. 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, so Time.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: AvaTaxProviderTests drives 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: MigrationsTests fails 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.