A repository for testing Test Coverage / Code Coverage frameworks, tools and libraries in Python which uses Flask / SQLAlchemy stack and Selenium as testing tool.
The following tools are required:
- Python 3 (preferably with a virtual environment manager like pyenv)
- dbmate and PostgreSQL client binaries for database migration
- Docker (preferably with Docker Compose v2) to spin up services
- Chrome for executing tests (which uses Selenium)
To setup and execute the project's tests, execute these steps:
-
Spin up the project's services
docker compose up -d
-
Create a local copy of
.env.localcp .env.local .env
-
After PostgreSQL is healthy, execute database migration
dbmate migrate
-
Install project's dependencies
pip install -r requirements.txt
-
Execute the tests
pytest --cov=. test
For running SonarQube analysis in this project you need to additionally install Just for running predefined tasks. After that you can do the following steps:
-
Follow the SonarQube tutorial to execute a local instance (preferably with Docker)
-
Accessing
localhost:9000, add a new project (manual) withprojectKey = test-cov-python -
Update the
SONAR_TOKENvariable inside.envwith the value shown in the previous step's project setup -
Download and add Sonar Scanner binary to
$PATH(<INSTALL_DIRECTORY>is the same as the one in the tutorial)export PATH=$PATH:<INSTALL_DIRECTORY>/bin
-
Execute the scan
just scan