> For the complete documentation index, see [llms.txt](https://docs.codeforlife.education/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.codeforlife.education/software-developer-guide/back-end/testing-strategy.md).

# Testing Strategy

How we test our back end

When a PR is submitted, a series of tests will be run with Github actions. It is fine to just submit your PR and let the tests run on Github. However, if the tests fail, you may need to run the tests locally to investigate what's going on, then either fix the tests, or fix your code.

## Running Python Tests Locally

To run Python tests, simply run at the top folder of the repository:

```
pytest -n auto
```

The `pytest` command will run both the tests written with [pytest](https://docs.pytest.org/) and those with the built-in python [unittest](https://docs.python.org/3/library/unittest.html).

{% hint style="info" %}
We are aiming to migrate all **unittest** to **pytest.** Meanwhile you will see a combination of these. If you write new tests, please use **pytest**.
{% endhint %}

For Rapid Router and Portal, `pytest` also runs [Selenium tests](/software-developer-guide/front-end/testing-strategy.md). Check the section below for what you need to install to run it.

The Python tests in Portal also include some snapshot tests. Running `pytest` will also automatically run the snapshot tests. When needed, the snapshot tests can be updated by running `pytest --snapshot-update`.
