Skip to content

#5: Add a test suite - #6

Merged
btreeby merged 5 commits into
mainfrom
add-testing-framework
Apr 21, 2026
Merged

#5: Add a test suite#6
btreeby merged 5 commits into
mainfrom
add-testing-framework

Conversation

@btreeby

@btreeby btreeby commented Apr 20, 2026

Copy link
Copy Markdown
Member

Add automated test suite and CI

Summary

Adds a MATLAB matlab.unittest test suite for the toolbox and wires it up to GitHub Actions so every push and PR runs the tests automatically.

Closes #5

What's in this PR

  • Unit tests (tests/unit/, 33 tests) covering the pure helpers in +petraToCT/+tools/ (radius2measure, getLargestCC, fillAllHoles, fillSmallHoles, applyHUMapping) and the histogram normalisation. All run in seconds and need no external tools or data.

  • Integration tests (tests/integration/, 4 tests) exercising debias, segmentationSPM, and the full convert pipeline against a small defaced PETRA fixture at tests/fixtures/petra.nii.gz. Gated with assumeTrue so they filter (not fail) when SPM or 3D Slicer aren't available. Intended for local pre-release runs; they report as filtered in CI.

  • Small refactor: extracted the hard-coded HU calibration (-1000 / 42 / -2929.6 * x + 3274.9) from convert.m into a new pure helper +petraToCT/+tools/applyHUMapping.m so the calibration numbers can be pinned by a unit test.

  • GitHub Actions workflow (.github/workflows/ci.yml) running the suite on ubuntu-latest with matlab-actions/setup-matlab@v3 (Image Processing + Signal Processing toolboxes) on every push to main and every PR.

  • README updated with a CI badge and a ## Testing section documenting how to run the suite locally.

Test plan

  • runtests("tests", IncludeSubfolders=true) passes locally (33 unit + 4 integration = 37 tests).
  • CI run on this branch is green — unit tier passes, integration tier filters correctly.
  • After merge, enable a branch protection rule on main requiring the MATLAB tests check.

Notes

  • The fixture (tests/fixtures/petra.nii.gz, 4.6 MB) is a defaced, 2 mm isotropic PETRA volume. Generation pipeline is documented in tests/fixtures/README.md.
  • Integration tests are slow (~15-20 min each for SPM) and intentionally run only locally.

@btreeby btreeby self-assigned this Apr 20, 2026
@btreeby
btreeby merged commit 338a90a into main Apr 21, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a test suite

1 participant