- One `SCENARIO("description")` per logical test group, with `[tag1][tag2]` annotations
- Shared fixture: all constants, structs, and variables declared between `SCENARIO` opening and first `SECTION`
- Precompute expected values analytically at fixture level (use `scripts/*.py` for complex simulations)
- Run `scripts/precalc_*.py` to generate expected values — these Python scripts are the authoritative source, providing an independent check against the C++ simulation. Embed the values directly in `WithinAbs()` calls (no need to declare named constants unless the value is reused).
### 2. Duplication Elimination
- Use lambdas that capture the fixture for repeated setup→call→assert patterns
@ -13,14 +13,18 @@
- Single-line `SECTION`s when body is one statement: `SECTION("name") { helper(arg); }`
### 3. Assertions
- Include `src/test_utilities.h` for tolerance constants and test utilities
- `#include <catch2/matchers/catch_matchers_floating_point.hpp>` (required for `WithinAbs` matcher)
- `using Catch::Matchers::WithinAbs;` after includes
- `REQUIRE_THAT(value, WithinAbs(expected, tolerance))` — never `Approx()`
- **Always use named tolerance constants** — never hardcode raw numbers for tolerance in `WithinAbs()`.
#### Tolerance Reference
All constants defined in `src/test_utilities.h` — use those, do not redefine locally.
- `INFO("label: " << value)` for debugging context
@ -42,14 +46,14 @@
- C++ tests typically use local coordinates (e.g., `vec3_distance(craft->local_position, (Vec3){0,0,0})`).
- Global distances are dominated by parent body positions (e.g., Earth-Sun distance swamps LEO orbit).
- **Always output SI units** (meters, m/s, seconds) — C++ tests use SI internally.
- Output C++-style comments with precalculated constants for embedding in the test.
- Output C++-style comments with precalculated expected values for embedding in the test. Tolerances are chosen separately by the test writer using the Tolerance Reference table — the precalc script should not output tolerance values.
- Run with: `python3 scripts/precalc_<test_name>.py`
- If sim_engine.py lacks a feature, use analytical formulas instead (**but notify the user what feature was missing**)
## Refactoring Procedure
### Step 1: Refactor
- Verify the test file has a TOML config in `old_tests/`. If it doesn't, skip — it's likely hardcoded.
- Verify the test file has a TOML config in `old_tests/`. If it doesn't, skip the TOML rewrite step — the test is likely hardcoded.
- Check if the test is already in `tests/` (already refactored). Skip if so.
- Check the capability matrix in Section 5 — if the test needs SOI, maneuvers, rendezvous, etc., flag this before starting.