python -m venv venv
.\venv\Scripts\activate
- Install pytest using pip (having virtual env activated)
python -m pip install pytest
- Install AltTester package using pip
pip install AltTester-Driver
In order for pytest to be able to identify test classes, used prefix test_
for filenames and test functions.
pytest
Use -s
in order to see printed output:
pytest -s <specific_file.py>
In order to run tests which use unittest
unit testing framework
python -m unittest test_recorder.py
Using allure to generate test reports
-
Download the latest allure package zip file from the allure framework GitHub
- Unzip the downloaded zip file
- Copy the path until bin file (including bin)
- Add it to path environment variable
-
Install allure-pytest adaptor using pip
pip install allure-pytest
Generate a folder(automatically named allure-report) to save allure reports using the following command:
allure generate
- Run the tests using the following command:
pytest --alluredir=allure-report <test_file.py>
- View the allure report previously generated
allure serve allure-report
After generating allure-report, when we need to save everything into one html file (to share it); install an external package which builds allure generated folder into one html file:
Requirements: Python 3.6+
pip install allure-combine
allure-combine package implementation and documentation
Then each time after running test, when want to save allure-report in one sharable HTML file:
allure generate -c allure-report -o allure-results-html
allure-combine ./allure-results-html
Parametrizing test functions using pytest.fixture()