1. Install pytest
pip install pytest
2. Report plugin allure
(1) Download allure and unzip
(2) Environment variable: path: bin directory
(3) Install the pytest-allure plugin
pip install allure-pytest
3.Pytest framework naming convention
(1) The .py test file must start with test_ or end with _test
(2) The test class must start with Test and cannot have an init method
(3) The test method must start with test_
(4) Asserts must use assert
4. pytest data-driven: parameterized test data
@pytest.mark.parametrize("x,y", test_Data) (x,y)=[(x1,y1),(x2,y2).........]
import pytest
test_Data = [(1, 2), (3, 4), (5, 6)]
@pytest.mark.parametrize("x,y", test_Data)
def test_sum(x, y):
print(x + y)
if __name__ == '__main__':
pytest.main(["模块名", "-s"])
operation result: