Is there a way to run all pytest cases from multiple folders?

pytest, python, testing, unit-testing

Solution

You can give pytest multiple folders to discover tests in:

python -m pytest projectfolder/A projectfolder/B

or if you want to use a config file:

# pyproject.toml
[tool.pytest.ini_options]
testpaths = [
    "projectfolder/A",
    "projectfolder/B",
]

Problem

Suppose I have `test_case1.py` in folder `A`, and `test_case2.py` in folder `B`. Can I run them together using a single `pytest` command? Folder structure: ``` projectfolder/A/test_case1.py projectfolder/B/test_case2.py ```

Original source

Related problems