Skip to content

about test

Kohei Noda edited this page Feb 8, 2024 · 11 revisions

About test

  • Test is a process to check if the program works as expected.
  • This project uses pytest to test.
  • The test is run automatically when you push to the main branch or create a pull request.
  • We recommend that you write unit tests for small feature units when creating new features.

Test items

  • This project tests whether the CASPT2 energy has an error of more than a certain amount. The error is allowed to be up to ±10-8 a.u.
  • For new features, we also create feature-level unit tests.

How to run tests

First time to run tests

  • You need to install pytest to run tests.
  • You can install pytest by running the following command (Python 3.6 or later is required).
python -m pip install pytest

Running tests

  • Once you have installed pytest, you can run the tests by running the following command.
pytest --dev

Marker

  • In this project, we use markers to avoid running unnecessary long tests according to the test execution time.

    # Run only the tests with @pytest.mark.dev
    pytest --dev
    # Run the tests with no marker and @pytest.mark.dev
    pytest
    # Run all tests
    pytest --all
    # Run only the tests with @pytest.mark.slowonly
    pytest --slowonly
    • If you are using a parallel compiler such as mpiifort, mpiifx, mpif90, or mpifort, and you have enabled the --mpi option at build time, we recommend that you run MPI parallel tests. The command is as follows.
    pytest --dev --mpi=4
    • we use Github Actions to automatically run tests for commits that upload (push) files such as *.f90, *.F90, *.cmake, CMakeLists.txt, *.py, and Github Actions files.
    • Github Actions settings are in .github/workflows/ci.yml.