Testing#
Testing for BridgeStan is primarily done through the higher-level interfaces.
All tests are based around the same set of test models (in the test_models/
folder).
You can build all of the test models at once with
make STAN_THREADS=true test_models -j<jobs>
Note: The additional functionality provided by
STAN_THREADS
is only tested by the Julia tests,
but in order to facilitate the same built models being used in
all tests we use it regardless of interface.
Tooling#
Python#
In Python we use pytest to run tests. Tests
are written using basic assert
statements and helper code from numpy.testing
.
The Python test suite has the ability to run mutually exclusive groups of code. This is to allow
testing of features such as the BRIDGESTAN_AD_HESSIAN
flag which change underlying code and
therefore cannot be loaded at the same time as models compiled without it.
Running
cd python/
pytest -v
Will run the “default” grouping. To run the other group(s), run
cd python/
pytest --run-type=ad_hessian -v
The set up for this can be seen in tests/conftest.py
and is based on the
Pytest documentation examples.
Julia#
Julia tests are written using the built in unit testing library.
julia --project=./julia -t 2 -e "using Pkg; Pkg.test()"
R#
R tests are written using testthat.
cd R/
Rscript -e "devtools::test()"
The R unit tests are much more basic than the Python or Julia tests.