Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed path starting tests #11

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 48 additions & 20 deletions docs/guide-dev/tests.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,59 @@
# Run Test Suite
# Test Suite

The test suite is located within the tests directory and is organized into two subdirectories: unit and selenium.
The unit directory contains unit tests, which focus on testing individual components of the project in isolation.
The selenium directory contains tests that utilize Selenium for browser-based testing,
ensuring that the user interface and web interactions function as expected.

## Run "Unit" tests
Unit tests are executed within a Docker container using the pytest framework.
This ensures a consistent testing environment, isolated from local machine configurations.

docker compose run --rm backend \
pytest \
-n auto \
-rP \
--create-db \
-p no:warnings \
--cov-report= \
--capture=sys \
hct_mis_api/ tests/
docker compose run --rm backend pytest -n auto --reruns 3 -rP -p no:warnings --cov-report= --capture=sys ./tests/unit


#### Analyze HTML Report

...

## Run "Selenium" functional test

...

#### Analyze HTML Report

...
Selenium tests run on the host machine.
This is due to the fact that Selenium does not currently support the ARM64 architecture for Linux Docker images.
This will require some more steps to be taken before running the tests.
### Prerequisites
- pdm

### Installation
1. **Services**

To run the tests locally, the following services are required:

1. **Postgres**
1. **Redis**
1. **Elasticsearch**

You can either install these services manually or use the `docker-compose` file located in the `development_tools` directory.

1. **Running Services with Docker Compose**

Make sure you have the required `.env` file from the backend setup, then you can run the services using the following command:

```bash
cd development_tools
docker compose --profile services up
1. Install system requirements
1. MACOS
1. `brew install wkhtmltopdf pango postgis gdal`
1. Crate virtual env
1. `pdm venv create`
1. Register the created venv for the project with
1. `pdm use`
1. Activate your venv
1. `eval $(pdm venv activate)`
1. Check your environment
1. eg. $`python --version` -> see that it uses Python 3.11.*
1. Install the packages
1. `pdm sync --no-editable --no-self --no-isolation`
1. Run the tests
1. `source ./development_tools/local_selenium_init.sh`
1. `python -m pytest -svvv ./tests/selenium --html-report=./report/report.html`

## Combine coverage and display reports

...
Loading