Skip to content

8.4 Testing and quality gates

./gradlew build is the gate before every commit and on every pull request, and offline. PIT is the exception in CI: it runs once, locally, before the push. There, backend/app and backend/evaluation alike mutate only the classes changed against origin/main, on two threads , and run only those classes' own tests — FooTest for Foo, the package's tests for a class without one. PIT's coverage pass runs every target test before the first mutant, so narrowing the tests is what keeps the pass from repeating the suite test has just run; the price is that a mutant only another class's test kills counts as surviving. CI skips PIT on a pull request and on a push to main alike (-x pitest). The full run — every class against every test (-PpitFull) — runs nightly on a dedicated machine outside CI (scripts/linux/nightly-mutation.sh; a night that machine is down is missed), and .github/workflows/nightly-mutation.yml stays for a manual run on GitHub's runners. The same nightly run starts with postgresIntegrationTest: the migrations and the PostgreSQL adapters against real PostgreSQL in a container, which build never reaches because it runs them on H2 in PostgreSQL mode. Its failure files its own [Bug] Nightly PostgreSQL run: … issue. The nightly machine was chosen over a CI service container because the run costs no GitHub minutes and needs no second schedule. The CI gate is .github/workflows/build.yml, the scope rule buildSrc/src/main/kotlin/PitScope.kt.

Gate Tool Threshold Where
Formatting Spotless with google-java-format no diff spotlessCheck; a hook blocks the commit
Static analysis Error Prone, as a compiler plugin checks of severity ERROR fail the build every compilation
Architecture ArchUnit with jMolecules: onion rings, DDD building blocks; @DisplayName on every test; no field injection. Spring Modulith: verify() on the modules, the module docs written to backend/app/build/spring-modulith-docs no violation OnionArchitectureTest, ArchitectureTest, ModularityTest
Tests JUnit Jupiter, AssertJ; plain JUnit without a Spring context for the stub tests; given/when/then all green test
Line coverage JaCoCo 90 % per class (not as a project average); the bootstrap class excluded jacocoTestCoverageVerification
Mutation testing PIT 95 %; the bootstrap class and the seven *Configuration classes excluded pitest
Web app TypeScript typecheck, Vitest, the production build of frontend/app all green :frontend:app
Consistency of the docling image the Cloud Run step's docling-serve image, sync wait and limits match compose.yaml and the client no mismatch checkDoclingImageInStep, checkDoclingSyncWaitInStep, checkDoclingLimitsInStep

Outside the gate, on purpose: integrationTest (Mistral, needs MISTRAL_API_KEY), vertexAiIntegrationTest (Gemini, needs GOOGLE_CLOUD_PROJECT and Application Default Credentials), doclingIntegrationTest (needs Docker), emulatorIntegrationTest (the async intake against the Pub/Sub emulator and fake-gcs-server in Docker, spec 264) and postgresIntegrationTest (needs Docker: PostgreSQL with pgvector, which the nightly run starts with). A smoke test against a real model asserts something the model can only get right by answering, so a dead connection cannot pass as good behaviour.

Testing the database

The offline gate needs no Docker, so it runs the database code on H2 in its PostgreSQL mode: the case store's and the outbox's migration files are loaded there with Flyway off, which is why they avoid what H2 lacks (8.3, Schema changes), and the case store and the event publication registry are tested against that. What H2 cannot show is tested against real PostgreSQL in the integration test source set, never in build:

Test Proves Task
PostgresMigrationTest an empty database is migrated, the vector extension works, and a tampered schema stops the start postgresIntegrationTest
PostgresCaseStoreIntegrationTest a case survives a restart, is kept until it is soft-deleted, and is claimed by one of two concurrent callers postgresIntegrationTest
PublicationResubmissionIntegrationTest an incomplete event publication is resubmitted under the advisory lock postgresIntegrationTest
DatabaseHealthTest with the database stopped, readiness is DOWN and liveness UP; it runs offline, against a data source nothing answers on test
the Playwright run pnpm test:e2e:postgres in the web app an upload through the screen leaves its case's row in the container, and the screen reads it back by hand, never in build