Code Add Tests
Table of Contents
When to use this skill
When you need to create or extend unit tests for an ORE Studio component. For investigating a failing test, use the sibling test-failure-investigator.
How to use this skill
The canonical reference for how an ORE Studio test looks is Unit test conventions — file layout, naming patterns, includes, test-case shape, tags, generators, database helpers. Read it first if you have not seen the contract.
- Identify component and layer — domain, repository, service,
security, messaging, or generators. This sets the file name
(
<layer>_<class>_tests.cpp), the include set, and the default tag ([<layer>]). - Pick the test categories you need:
- Domain: basic construction, JSON serialisation, faker-generated data.
- Repository: write single, write batch, read latest, read by field, temporal queries.
- Messaging: serialize/deserialize roundtrip (empty + populated).
- Generators: generator produces valid entity, batch generator produces N.
- Write each test case following the standard shape from
Unit test conventions§"Test-case shape":
auto lg(make_logger(test_suite));at the top.- Build the system under test (use a generator when available).
BOOST_LOG_SEV(lg, info) << sut;before assertions.CHECKfor non-fatal;REQUIREfor "rest of case is pointless if this fails".
- Pick the right database helper for repository tests
(
database_helpervsscoped_database_helper— see Unit test conventions§"Database helpers"). New components preferscoped_database_helper(tenant-isolated, no truncation needed). - Build and run the new tests via How do I build the system? and How do I run the tests? — confirm everything passes locally before pushing.
- Self-check against the reviewer checklist — the "Unit tests" section of Code review checklist is what reviewers will apply.
Recipes
- How do I build the system? — build the test target.
- How do I run the tests? — run the new tests.
- How do I enable test logging? — if you want to see your
BOOST_LOG_SEVoutput during iteration.
Reference
- Unit test conventions — the canonical patterns and helpers.
- Code review checklist§"Unit tests" — reviewer-side checks.
- Unit Test Database Integration Guide — deeper database-side
reference inside
ores.testing. - test-failure-investigator — sibling skill for when a test goes red.