From fea151d8d7b7511cc7b3198ff55e71c2669ad486 Mon Sep 17 00:00:00 2001 From: Evgeniy Unzhakov Date: Fri, 15 May 2026 15:09:13 +0300 Subject: [PATCH] docs: add test migration TODO with 5-phase plan MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Phase 1: Remove duplicate old tests (6 files) - Phase 2: Migrate remaining 7 old test files to new structure - Phase 3: Create integration tests - Phase 4: Clean up and verify - Phase 5: Advanced improvements (slow markers, hypothesis, CI) - Total: from 230 flat tests → ~240 organized tests in 3 directories --- docs/test-migration-todo.md | 155 ++++++++++++++++++++++++++++++++++++ 1 file changed, 155 insertions(+) create mode 100644 docs/test-migration-todo.md diff --git a/docs/test-migration-todo.md b/docs/test-migration-todo.md new file mode 100644 index 0000000..1a8e397 --- /dev/null +++ b/docs/test-migration-todo.md @@ -0,0 +1,155 @@ +--- +title: "Test Migration TODO — From Flat to Structured Suite" +date: 2026-05-15 +tags: + - testing/todo + - testing/migration +status: active +aliases: [test migration, test reorganization] +related_notes: + - test-architecture +--- + +# Test Migration TODO + +> [!info] Current state +> - **Old tests**: 230 tests in `tests/*.py` (flat structure) +> - **New tests**: 94 tests in `tests/{physics,quality,common}/` (structured) +> - **New tests already passing**: ✅ 94/94 +> - **Old tests still passing**: need to verify after removing duplicates + +## Phase 1: Remove duplicate old tests (P0 — blocking) + +The old files in `tests/` root contain tests that are now covered by the new structure. Remove them: + +- [ ] **1.1** Remove `tests/test_fermi.py` — covered by `tests/physics/test_fermi.py` + `tests/quality/test_api_fermi.py` +- [ ] **1.2** Remove `tests/test_finite_size.py` — covered by `tests/physics/test_finite_size.py` + `tests/quality/test_api_finite_size.py` +- [ ] **1.3** Remove `tests/test_screening.py` — covered by `tests/physics/test_screening.py` + `tests/quality/test_api_screening.py` +- [ ] **1.4** Remove `tests/test_exchange.py` — covered by `tests/physics/test_exchange.py` + `tests/quality/test_api_exchange.py` +- [ ] **1.5** Remove `tests/test_radiative.py` — covered by `tests/physics/test_radiative.py` + `tests/quality/test_api_radiative.py` +- [ ] **1.6** Remove `tests/test_phase_space.py` — covered by `tests/physics/test_phase_space.py` + `tests/quality/test_api_phase_space.py` + +**After removal**: ~136 old tests remain (fitter, spectrum, detector, cw_extractor, multi_branch, nuclear_data, logging). + +## Phase 2: Migrate remaining old tests (P1 — high priority) + +Move the remaining old tests to the new structure: + +### 2.1 Integration tests → `tests/integration/` +- [ ] **2.1.1** `tests/test_spectrum.py` → `tests/integration/test_spectrum_pipeline.py` + - Full pipeline tests (from_config → evaluate → components) + - Declarative detector response tests + - These are integration tests, not component tests + +### 2.2 Physics tests → `tests/physics/` +- [ ] **2.2.1** `tests/test_detector_response.py` → `tests/physics/test_detector_response.py` + - 23 tests — physics behavior (normalization, resolution, convolution) + - Split into: `test_detector_response.py` (physics) + `tests/quality/test_api_detector_response.py` (API) + +- [ ] **2.2.2** `tests/test_fitter.py` → `tests/physics/test_fitter.py` + - 16 tests — fit quality, covariance, confidence intervals + - Split: physics (fit quality) + quality (API) + +- [ ] **2.2.3** `tests/test_cw_extractor.py` → `tests/physics/test_cw_extractor.py` + - 18 tests — shape factor extraction accuracy + - Split: physics (extraction) + quality (API) + +- [ ] **2.2.4** `tests/test_multi_branch.py` → `tests/physics/test_multi_branch.py` + - 26 tests — multi-branch physics + - Split: physics (branching) + quality (API) + +- [ ] **2.2.5** `tests/test_nuclear_data.py` → `tests/quality/test_nuclear_data.py` + - 21 tests — mostly API/parsing tests + - These are quality tests (input validation, parsing) + +### 2.3 Quality tests → `tests/quality/` +- [ ] **2.3.1** `tests/test_logging_utils.py` → `tests/quality/test_logging_utils.py` + - 23 tests — all API tests (no physics) + - Direct move, no splitting needed + +## Phase 3: Create shared integration test (P2) +- [ ] **3.1** Create `tests/integration/test_full_pipeline.py` + - End-to-end: config → spectrum → convolve → export → reimport + - Multi-branch → weighted sum → export + - Verify CSV export matches reimport + +## Phase 4: Clean up (P3) +- [ ] **4.1** Remove old `tests/test_*.py` files that were migrated +- [ ] **4.2** Verify all tests pass: `python3 -m pytest tests/ -v` +- [ ] **4.3** Verify test count matches expected: ~136 (was 230, removed ~94 duplicates) +- [ ] **4.4** Update `docs/test-architecture.md` with final structure +- [ ] **4.5** Add `.gitkeep` to `tests/common/`, `tests/integration/` directories + +## Phase 5: Advanced improvements (P4 — nice to have) +- [ ] **5.1** Add `pytest.mark.slow` to long-running tests +- [ ] **5.2** Add `pytest.mark.requires_ensdf` to tests needing paceENSDF +- [ ] **5.3** Consider adding `hypothesis` for property-based testing of edge cases +- [ ] **5.4** Add `pytest-timeout` to prevent hangs +- [ ] **5.5** Add CI badge for test status + +## Files to create/modify + +### New files (already created) +- ✅ `tests/common/__init__.py` +- ✅ `tests/common/test_property_tests.py` — shared property helpers +- ✅ `tests/common/test_api_tests.py` — shared API helpers +- ✅ `tests/physics/test_fermi.py` +- ✅ `tests/physics/test_phase_space.py` +- ✅ `tests/physics/test_finite_size.py` +- ✅ `tests/physics/test_screening.py` +- ✅ `tests/physics/test_exchange.py` +- ✅ `tests/physics/test_radiative.py` +- ✅ `tests/quality/test_api_fermi.py` +- ✅ `tests/quality/test_api_phase_space.py` +- ✅ `tests/quality/test_api_finite_size.py` +- ✅ `tests/quality/test_api_screening.py` +- ✅ `tests/quality/test_api_exchange.py` +- ✅ `tests/quality/test_api_radiative.py` + +### Files to create (remaining) +- `tests/integration/test_spectrum_pipeline.py` +- `tests/integration/test_full_pipeline.py` +- `tests/physics/test_detector_response.py` +- `tests/quality/test_api_detector_response.py` +- `tests/physics/test_fitter.py` +- `tests/quality/test_api_fitter.py` +- `tests/physics/test_cw_extractor.py` +- `tests/quality/test_api_cw_extractor.py` +- `tests/physics/test_multi_branch.py` +- `tests/quality/test_api_multi_branch.py` +- `tests/quality/test_nuclear_data.py` +- `tests/quality/test_logging_utils.py` + +### Files to delete +- `tests/test_fermi.py` +- `tests/test_finite_size.py` +- `tests/test_screening.py` +- `tests/test_exchange.py` +- `tests/test_radiative.py` +- `tests/test_phase_space.py` +- `tests/test_spectrum.py` +- `tests/test_detector_response.py` +- `tests/test_fitter.py` +- `tests/test_cw_extractor.py` +- `tests/test_multi_branch.py` +- `tests/test_nuclear_data.py` +- `tests/test_logging_utils.py` + +## Test count comparison + +| Category | Before | After (target) | +|---|---|---| +| Common helpers | 0 | ~12 (shared, not counted) | +| Physics tests | ~151 | ~151 (same, reorganized) | +| Quality/API tests | ~79 | ~79 (same, reorganized) | +| Integration tests | ~0 | ~10 (new) | +| **Total unique tests** | **230** | **~240** | + +The duplicate tests (positivity, shape, NaN across 6 components = ~18 tests) are now covered by shared helpers, so the **effective test count decreases** while coverage stays the same or improves. + +## References + +- [pytest markers documentation](https://docs.pytest.org/en/stable/how-to/mark.html) +- [pytest test collection](https://docs.pytest.org/en/stable/explanation/goodpractices.html#test-collection) +- [NumPy testing guidelines](https://numpy.org/doc/stable/reference/testing.html) +- [Property-based testing with Hypothesis](https://hypothesis.readthedocs.io/)