Testing ======= Testing for BridgeStan is primarily done through the higher-level :doc:`interfaces <../languages>`. All tests are based around the same set of test models (in the :file:`test_models/` folder). You can build all of the test models at once with .. code-block:: shell make STAN_THREADS=true test_models -j Note: The additional functionality provided by :makevar:`STAN_THREADS` is only required by the Julia and Rust tests, but in order to facilitate the same built models being used in all tests we use it regardless of interface. Python ______ In Python we use `pytest `__ to run tests. Tests are written using basic ``assert`` statements and helper code from :py:mod:`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 :makevar:`BRIDGESTAN_AD_HESSIAN` flag which change underlying code and therefore cannot be loaded at the same time as models compiled without it. Running .. code-block:: shell pytest -v python/ Will run the "default" grouping. To run the other group(s), run .. code-block:: shell pytest --run-type=ad_hessian -v python/ The set up for this can be seen in :file:`tests/conftest.py` and is based on the `Pytest documentation examples `__. Julia _____ Julia tests are written using the built in `unit testing library `__. .. code-block:: shell julia --project=./julia -t 2 -e "using Pkg; Pkg.test()" R _ R tests are written using `testthat `__. .. code-block:: shell cd R/ Rscript -e "devtools::test()" The R unit tests are much more basic than the Python or Julia tests. Rust _____ The Rust tests can be run with :command:`cargo` .. code-block:: shell cd rust/ cargo test