Generate a repository test for every entity, and retire the hand-written ones

Table of Contents

This page is a capture in the inbox bucket of the product backlog — a pre-sprint idea, not yet pulled into a sprint as a story.

1. What

Add a codegen archetype that generates a repository test for each entity: write and read latest, read a key that does not exist, and remove. Then delete the hand-written repository tests that the generated ones replace. Keep a hand-written test only where it covers a hand-written repository method or a case the template cannot state, and record why.

Today codegen generates no repository test. The only generated C++ tests are the eventing integration tests (41 in ores.trading). The repository tests are all hand-written: 90 files across 12 components, measured 2026-10-02:

Component Hand-written repository test files
ores.refdata 26
ores.trading 19
ores.dq 16
ores.iam 11
ores.analytics 4
ores.reporting, ores.marketdata, ores.assets 3 each
ores.scheduler 2
ores.workspace, ores.telemetry, ores.compute 1 each

In ores.trading the 19 files cover 9 equity and 7 FX instruments, plus activity_type, bond_leg_amount and trade_type. The component has 85 models, so most of its generated repositories have no repository test at all.

2. Why

The repository code is generated, but its tests are not. So the coverage depends on which entities someone happened to test by hand. A template defect in the repository layer reaches every entity, but only the tested ones can catch it. The hand-written tests are also the largest group of hand-written files in a clean component: in ores.trading they are 19 of the 83. Each trading file holds the same three cases, so the shape is mechanical and suits a template. The V07 vacuous-test census had to strengthen these files by hand; a generated test gets that fix once, in the template.

3. References

  • projects/ores.trading/core/tests/repository_fx_forward_instrument_repository_tests.cpp: a typical hand-written file.
  • projects/ores.codegen/library/templates/ores.cpp.eventing-integration-test.org: the one generated test archetype, as a model for the new one.

4. See also

Emacs 29.3 (Org mode 9.6.15)