- 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
6.8 KiB
title, date, tags, status, aliases, related_notes
| title | date | tags | status | aliases | related_notes | |||||
|---|---|---|---|---|---|---|---|---|---|---|
| Test Migration TODO — From Flat to Structured Suite | 2026-05-15 |
|
active |
|
|
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 bytests/physics/test_fermi.py+tests/quality/test_api_fermi.py - 1.2 Remove
tests/test_finite_size.py— covered bytests/physics/test_finite_size.py+tests/quality/test_api_finite_size.py - 1.3 Remove
tests/test_screening.py— covered bytests/physics/test_screening.py+tests/quality/test_api_screening.py - 1.4 Remove
tests/test_exchange.py— covered bytests/physics/test_exchange.py+tests/quality/test_api_exchange.py - 1.5 Remove
tests/test_radiative.py— covered bytests/physics/test_radiative.py+tests/quality/test_api_radiative.py - 1.6 Remove
tests/test_phase_space.py— covered bytests/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_*.pyfiles 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.mdwith final structure - 4.5 Add
.gitkeeptotests/common/,tests/integration/directories
Phase 5: Advanced improvements (P4 — nice to have)
- 5.1 Add
pytest.mark.slowto long-running tests - 5.2 Add
pytest.mark.requires_ensdfto tests needing paceENSDF - 5.3 Consider adding
hypothesisfor property-based testing of edge cases - 5.4 Add
pytest-timeoutto 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.pytests/integration/test_full_pipeline.pytests/physics/test_detector_response.pytests/quality/test_api_detector_response.pytests/physics/test_fitter.pytests/quality/test_api_fitter.pytests/physics/test_cw_extractor.pytests/quality/test_api_cw_extractor.pytests/physics/test_multi_branch.pytests/quality/test_api_multi_branch.pytests/quality/test_nuclear_data.pytests/quality/test_logging_utils.py
Files to delete
tests/test_fermi.pytests/test_finite_size.pytests/test_screening.pytests/test_exchange.pytests/test_radiative.pytests/test_phase_space.pytests/test_spectrum.pytests/test_detector_response.pytests/test_fitter.pytests/test_cw_extractor.pytests/test_multi_branch.pytests/test_nuclear_data.pytests/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.