Testing guide
Start with the test that can directly verify the behavior: a unit test for parsing rules, a real database for transactions, or an integration test for a workflow across modules. The semantic verification guide lists suites, commands, and coverage for execution behavior.
Test layers
Section titled “Test layers”| Layer | Scope | Typical use |
|---|---|---|
| Unit | One class or pure rule | Parsing, validation, routing, state transitions, and error mapping. |
| Module integration | One Maven module with its dependencies | Spring wiring, generated code, resource lifecycle, and provider behavior. |
| Store contract | A real first-party database Provider | Transaction, migration, locking, lease, and recovery semantics. |
| Cross-module integration | Engine, Deploy, Durable, or Server together | Public workflows and the exact effective version. |
| Workbench | pnpm workspace | TypeScript, contract, UI, and browser behavior. |
Tests must be deterministic. Do not depend on execution order, a developer home directory, the default timezone, uncontrolled external services, or static state left by an earlier test. Database and browser suites must declare and provision their infrastructure explicitly.
Java tests
Section titled “Java tests”Keep tests in the corresponding production module. Test public behavior through public APIs where possible, and name each test for the rule it checks. For a defect fix, write a regression test with the smallest input that reproduces the problem.
For concurrency and lifecycle code:
- use latches, barriers, or a controllable clock instead of arbitrary sleeps;
- check who releases resources, when cancellation takes effect, whether stale lease tokens are rejected, and when shutdown completes;
- close executors, class loaders, database connections, and child processes;
- verify successful execution and cases where an error must prevent further execution.
Tests of generated Java code should check output values and execution behavior. Avoid assertions that depend on incidental formatting. A source snapshot is useful only when the emitted structure is itself a contract.
Persistence tests
Section titled “Persistence tests”Migration and transaction behavior must be verified against the supported first-party databases used by the feature. Use the exact PostgreSQL and MySQL versions pinned in release-baselines.json for the required release matrix. Supported surfaces lists the modules that support them. H2 tests do not establish production database compatibility.
For a persistence change, cover:
- clean schema creation and migration admission;
- commit and rollback behavior;
- concurrent claims or compare-and-set transitions;
- restart, lease expiry, and recovery behavior when applicable;
- exact error or dead-letter handling.
Provider implementations must pass their provider-neutral Store testkit.
When changing a schema, persisted format, or identity rule, verify that saved values can be read back under the same rules. Use fixed inputs and expected results to check encoding and digests; determine the expected results independently of the implementation under test. Check size boundaries and reject unknown or malformed schemas and data formats.
Reopen saved data and exercise affected restart recovery, live Waits, unfinished Effects, and retained terminal results. A codec round trip alone does not establish those behaviors. See Versions and data integrity for supported combinations and data-integrity requirements.
Spring and Server tests
Section titled “Spring and Server tests”Load only the Spring context needed by the test. Check that required components are present, incomplete Store configuration prevents startup, and disabled optional features do not unexpectedly require a database.
Server endpoint tests cover request validation, authentication modes, Problem Details, OpenAPI structure, database changes, and idempotency. Workbench Server /api/** is paired with the frontend from the same release. When changing it, update controller types, the OpenAPI snapshot, generated frontend types, runtime validation, and tests together.
Targeted commands
Section titled “Targeted commands”Configure a supported JDK as described in Contributing, then run ./mvnw -version to check which JDK Maven actually uses. Run the commands below from the repository root.
For example, run the Core event-publishing test. Replace the module and test class when checking a different behavior:
./mvnw -pl compileflow-core -am -Dtest=ProcessEventPublisherTest -Dsurefire.failIfNoSpecifiedTests=false testAfterward, inspect the target module’s target/surefire-reports. Confirm that the selected test ran with no failures or errors. failIfNoSpecifiedTests=false allows prerequisite modules to have no matching tests; a successful build alone does not establish that the target test ran.
Replace <module> and <TestClass> in the following commands with actual names before running them.
Build dependent modules from the reactor:
./mvnw -pl <module> -am -DskipTests compileRun a focused integration test:
./mvnw -pl compileflow-integration-tests -am -Dtest=<TestClass> -Dsurefire.failIfNoSpecifiedTests=false testArchitecture source checks need JDK 17 or newer: set JAVA_HOME, or put java and javac on PATH. They parse Java 17 syntax, recognize fully qualified references, and skip comments and strings. Reflection strings still need separate review, and type checking remains the compiler’s job.
Create a Python 3.12 environment, install the pinned Markdown parser dependencies, then run the documentation and architecture checks from the repository root:
python3.12 -m venv target/docs-venvtarget/docs-venv/bin/python -m pip --isolated install \ --index-url https://pypi.org/simple --only-binary=:all: --require-hashes \ -r scripts/requirements-docs.txt. target/docs-venv/bin/activatepython3 scripts/check_repository_hygiene.pypython3 scripts/check_bilingual_parity.pypython3 scripts/check_architecture_boundaries.pypython3 scripts/check_spec_impl_parity.pygit diff --checkRun the Workbench checks from compileflow-workbench using the scripts in its package.json, normally:
pnpm type-checkpnpm testpnpm buildWhen a change affects a browser workflow, run its Playwright tests and explicitly configure the Server and browser targets. An unavailable target must cause a failure, not silently skip tests that should have run.
Use a dedicated environment because browser integration tests create definitions, versions, deployments, and invocations. The shared suites open and cancel the confirmations for global dead-letter requeue and execution-log purge; they do not execute those global operations. Retry tests use only invocation IDs they created. Isolated component and Server tests verify successful global maintenance.
Executable Server smoke test
Section titled “Executable Server smoke test”When a change affects packaging, configuration, migrations, authentication, or cross-module wiring, run the packaged Server as an executable JAR with a supported database. Verify startup, schema admission, one authenticated request, one process execution, one deployment operation when enabled, and graceful shutdown. A unit test or H2 run alone is insufficient evidence for these changes.
Failure diagnosis
Section titled “Failure diagnosis”For an intermittent failure, retain the seed, input, thread state, database logs, and relevant configuration in a protected location. Redact secrets and business data before sharing diagnostics. Determine whether the cause is a product race, resource leak, environment dependency, or unstable test. Fix the cause and add a repeatable regression test. Longer sleeps, weaker assertions, and unlimited retries hide the problem.
Submission checklist
Section titled “Submission checklist”- New behavior has a test; a fixed defect has a regression test.
- Tests prove the public contract at the narrowest appropriate layer.
- Concurrency and timing tests use controlled synchronization and clocks.
- Persistence changes are verified on each relevant supported Provider.
- API, configuration, REST, schema, wire, and generated-client changes cover their corresponding contract layers.
- Relevant tests and repository checks have passed on the reviewed source; the required suites ran without unaccounted skips. A release also needs its same-commit CI and database matrix evidence.
- Generated build artifacts are excluded from the submitted changes.