https://docs.pytest.org/en/6.2.x/example/simple.html
https://stackoverflow.com/questions/22627659/run-code-before-and-after-each-test-in-py-test
Pass variables via command line using pytest_addoption
in conftest.py:
Wrap setup and teardown steps into corresponding functions:
Setup browsers before each test, and close browser after each test (no matter test pass or failed):
https://stackoverflow.com/questions/44441929/how-to-share-global-variables-between-tests
https://docs.pytest.org/en/6.2.x/deprecations.html#pytest-namespace
Set the variable to the pytest variable us pytest_namespace
or pytest_configure
(depends on the pytest version):
Can use it directly in the test case as the following:
pytest-ordering
https://github.com/ftobia/pytest-ordering
For example,
pytest-depends
https://pypi.org/project/pytest-depends/
For example,
The test will skip if the dependent test fails:
https://iter01.com/544649.html
Include test cases in class, and load test data from conftest.py
Command line to run pytest and pass arguments:
Result of running test:
Result of running test:
ERROR: setup_class() missing 1 required positional argument
setup_module
and setup_class
happen earlier than @pytest.fixture(autouse=True)
https://stackoverflow.com/questions/56402600/pytest-calling-a-fixture-from-another-fixture
For example, a fixture uses another fixture from conftest.py file:
python
pytest
test automation
software test
tdd
unit test