# Testing Strategy

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`.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.codeforlife.education/software-developer-guide/back-end/testing-strategy.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
