Skip to content

Commit 88e4841

Browse files
committed
docs(testing): improve tox test execution and document workflow
This improves the developer experience by making the testing workflow more discoverable and flexible. - Updates `tox.ini` to use `posargs` with default values for the test environments. This allows developers to run the full test suite by default, or easily specify a single test file to run. - Adds `description` fields to the unit and functional test environments in `tox.ini`. This makes instructions on how to run specific tests visible in the output of `tox list`. - Updates `CONTRIBUTING.rst` with concrete examples for running specific unit, API functional, and CLI functional tests, aligning the documentation with the new `tox` configuration.
1 parent 3eda669 commit 88e4841

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

CONTRIBUTING.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ You need to install ``tox`` (``pip3 install tox``) to run tests and lint checks
111111
# run unit tests in one python environment only (useful for quick testing during development):
112112
tox -e py311
113113
114+
# run a specific unit test file:
115+
tox -e py311 -- tests/unit/objects/test_projects.py
116+
114117
# run unit and smoke tests in one python environment only
115118
tox -e py312,smoke
116119
@@ -148,9 +151,15 @@ To run these tests:
148151
# run the CLI tests:
149152
tox -e cli_func_v4
150153
154+
# run a specific CLI functional test file:
155+
tox -e cli_func_v4 -- tests/functional/cli/test_cli_v4.py
156+
151157
# run the python API tests:
152158
tox -e api_func_v4
153159
160+
# run a specific API functional test file:
161+
tox -e api_func_v4 -- tests/functional/api/test_projects.py
162+
154163
When developing tests it can be a little frustrating to wait for GitLab to spin
155164
up every run. To prevent the containers from being cleaned up afterwards, pass
156165
``--keep-containers`` to pytest, i.e.:

tox.ini

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ passenv =
2626
NO_COLOR
2727
PWD
2828
PY_COLORS
29+
USER
2930
setenv =
3031
DOCS_SOURCE = docs
3132
DOCS_BUILD = build/sphinx/html
@@ -35,10 +36,13 @@ usedevelop = True
3536
install_command = pip install {opts} {packages} -e .
3637
isolated_build = True
3738

39+
40+
[testenv:py{314,313,312,311,310}]
41+
description = Runs unit tests. For a specific test: tox -e py311 -- <path>
3842
deps = -r{toxinidir}/requirements.txt
3943
-r{toxinidir}/requirements-test.txt
4044
commands =
41-
pytest tests/unit {posargs}
45+
pytest {posargs:tests/unit}
4246

4347
[testenv:black]
4448
basepython = python3
@@ -131,14 +135,18 @@ exclude_lines =
131135
return NotImplemented
132136

133137
[testenv:cli_func_v4]
138+
description =
139+
Runs CLI functional tests. For a specific test: tox -e cli_func_v4 -- <path>
134140
deps = -r{toxinidir}/requirements-docker.txt
135141
commands =
136-
pytest --script-launch-mode=subprocess --cov --cov-report xml tests/functional/cli {posargs}
142+
pytest --script-launch-mode=subprocess --cov --cov-report xml {posargs:tests/functional/cli}
137143

138144
[testenv:api_func_v4]
145+
description =
146+
Runs API functional tests. For a specific test: tox -e api_func_v4 -- <path>
139147
deps = -r{toxinidir}/requirements-docker.txt
140148
commands =
141-
pytest --cov --cov-report xml tests/functional/api {posargs}
149+
pytest --cov --cov-report xml {posargs:tests/functional/api}
142150

143151
[testenv:smoke]
144152
deps = -r{toxinidir}/requirements-test.txt

0 commit comments

Comments
 (0)