Skip to content

parity-tests.json

parity-tests.json defines the behavior preservation test inventory. Parity testing is the mechanism that ensures modernized code behaves identically to the legacy system. Without parity tests, migration is guesswork.

{
"strategy": "behavior-preservation",
"suites": [
{
"context": "Accounts",
"tests": 68,
"type": "functional-parity",
"command": "bun test src/accounts/",
"baseline": "legacy-snapshots/accounts/"
},
{
"context": "Tax",
"tests": 24,
"type": "functional-parity",
"command": "bun test src/tax/",
"baseline": "legacy-snapshots/tax/"
},
{
"context": "Stock",
"tests": 0,
"type": "functional-parity",
"command": "bun test src/stock/",
"baseline": "legacy-snapshots/stock/"
}
],
"acceptance": {
"parity_threshold": 0.95,
"regression_tolerance": 0
}
}
FieldTypeRequiredDescription
strategystringYesTesting strategy: "behavior-preservation", "contract-driven", "shadow-testing"

Each entry describes a parity test suite for a bounded context:

FieldTypeRequiredDescription
contextstringYesThe bounded context this suite covers
testsnumberYesNumber of tests in the suite
typestringYesTest type: "functional-parity", "data-parity", "api-parity"
commandstringYesCommand to run the test suite
baselinestringYesPath to legacy behavior snapshots/recordings
FieldTypeRequiredDescription
parity_thresholdnumberYesMinimum parity percentage (0.0 to 1.0). 0.95 means 95% of tests must pass.
regression_tolerancenumberYesNumber of regressions allowed. 0 means zero tolerance for regressions.

The default strategy. Each legacy business rule maps to a test that verifies the modern implementation produces identical output.

DimensionMethod
Data modelField-by-field mapping (legacy schema to modern struct)
Business rulesRule-by-rule comparison with test evidence
Error handlingLegacy exception to modern error mapping
Edge casesTable-driven tests covering boundary conditions
IntegrationRealistic data from the legacy system

Define expected behavior as contracts. Both legacy and modern systems must satisfy the same contracts. Uses tools like Pact.

Run both systems in parallel with real traffic. Compare responses. Uses tools like Diffy or GoReplay.

TypeWhat It VerifiesExample
functional-parityBusiness logic produces identical outputTax calculation returns same amounts
data-parityData structures match between systemsGL entries have same fields and values
api-parityAPI responses are identicalSame request produces same JSON response

The baseline path points to captured legacy behavior. This can be:

  • JSON snapshots of legacy API responses
  • Database dumps of legacy computation results
  • Recorded test data from the legacy system
  • Golden files with expected outputs

These baselines serve as the source of truth for parity verification.

0.95 (95%) is the recommended starting threshold. This allows for minor differences in formatting, whitespace, or precision while catching functional regressions.

A threshold of 1.0 is appropriate for financial calculations where exact precision matters.

0 is recommended. Any test that was previously passing should never start failing. If a change causes a regression, it must be fixed before merging.

After modifying any extracted module:

  1. Read parity-tests.json to find the relevant test suite
  2. Run the command specified in command
  3. Compare results against the acceptance thresholds
  4. If tests fail below threshold, the modification should not be considered complete