aqnwb 0.1.0
Loading...
Searching...
No Matches
Testing

Unit Tests

AqNWB uses ctest and CATCH2 for unit testing. Relevant files for the unit tests are located at:

  • /tests : Sources of the unit tests
  • /tests/examples : Sources of example code used in the docs. The examples are implemented like regular unit tests but their purpose is to provide examples for the docs (rather than testing specific cases) and as such commonly include Doxygen section markers to allow inclusion of sections of code in the Doxygen docs.

Running Unit Tests

If you built AqNWB with the dev mode preset, then simply call:

ctest --preset=dev

Alternatively go to your build directory and run ctest directly, e.g.:

cd <my_build_dir>
ctest

Automated tests on GitHub

AqNWB uses GitHub Actions defined in the .github/workflows folder to automatically run all unit tests, spellchecks, linter, etc. on all pull requests.

Note
For pull requests, GitHub Actions often checks out a temporary merge commit. This commit represents the state of the code as if the pull request were to be merged into the target branch (usually main). This allows the CI to test the combined code without actually merging it. These temporary merge commits are not part of the repository's history and exist only in the context of the CI job. That is, if you are experiencing errors in the CI but the indicated lines of code do not match the code in the PR, then this is likely due the PR being out-of-sync with the target branch of the PR.

Spellcheck

AqNWB uses codespell to check the code for spelling errors. You can run the spellchecker via:

cmake --build --preset=dev --target=spell-check

To automatically fix spelling errors you can run codespell via the spell-fix target instead:

cmake --build --preset=dev --target=spell-fix
Note
codespell uses a relatively small dictionary of common misspellings and their corrections. For more comprehensive spellchecking (in particular of the documentation) additional spellchecking via more detailed spellcheckers (e.g., aspell) is recommended.

Linting

AqNWB uses clang-format for linting the code. You can run the linter via:

cmake --build --preset=dev --target=format-check

To automatically fix formatting errors you can run the linter via the format-fix target instead:

cmake --build --preset=dev --target=format-fix