To test Tracim, you first need to be able to build the backend and the frontend. See how to build.
In backend directory.
You need to setup tools and directories (only needed once):
python3 ./setup_dev_env.py
./create_test_storage_dir.shYou will need docker compose to run the backend tests. For Debian-based systems, you can install it with:
sudo apt install docker.io docker-compose-pluginSee installation instructions if you are not using Debian-based systems.
Finally, add the current user to docker group, you'll need to use a new login shell for this change to be taken into account
sudo usermod -a -G docker $USERTo test every databases, you will need the pytest-forked plugin.
pip install pytest-forkedTo run backend tests, you need several configurations:
- A specific configuration for specific tests is
available in
TEST_CONFIG_FILE_PATH(by default:./tests_configs.iniin backend folder). - For a more general configuration, pytest rely on dotenv
.envfile (by default.test.envin backend folder) - If you want to change general configuration like paths or database used, you should use environment variables instead of modifying
TEST_CONFIG_FILE_PATHfile or.test.env.
For example, if you want to use another database:
export TRACIM_SQLALCHEMY__URL=sqlite:/tmp/mydatabase
python3 ./setup_dev_env.py
pytestOrder of usage is (from less to more important, last is used if set):
- specific TEST_CONFIG_FILE_PATH config (different for each test)
- default env var setting in .test.env
- env var set by user
Run tests with the following commands:
docker compose up -d
pytest
docker compose downBy default the tests will be executed with the sqlite database, this can be changed using the --database argument of pytest:
pytest --database=postgresqlPossible databases are sqlite, postgresql, mysql and mariadb.
It is possible to specify several databases or even all:
pytest --forked --database=sqlite --database=postgresqlRun tests on all databases.
pytest --forked --database=allThe docker-compose.yml file lists the services needed for testing the Tracim backend.
To do the functional tests, you need to have Cypress installed.
To install Cypress and its dependencies, run:
./setup_functionnal_tests.shThis script uses sudo, make sure it is installed and configured. Alternatively, under root:
./setup_functionnal_tests.sh rootIf you need to run Cypress with an external server of Tracim, modify "baseurl" in cypress.json (more details here).
To run every unit tests:
./run_frontend_unit_test.shYou can also test a specific frontend application by doing:
yarn run testFor example, to test the agenda frontend application:
cd frontend_app_agenda
yarn run testTo run every functional tests:
./run_dev_backend.sh cypress runYou can also run cypress with a graphical interface:
./run_dev_backend.sh cypress openFor more advanced usage, refer to the cypress documentation.