一、Fixture用例分组运行常用于冒烟测试,分模块运行等
pytest.ini配置文件中增加分组参数markers来实现用例分组,如:
markers =
g1:组一
smoke:冒烟测试
pytest.ini内容如下:
[pytest] addopts = -s --html=./report.html testpaths = ./pytest-demo.py python_files = pytest*.py python_classes = Test* python_functions = test* markers = g1:组一 smoke:冒烟用例
测试用例内容如下:
import pytest @pytest.mark.g1 def test01(): print('test01') @pytest.mark.smoke def test02(): print('test02') if __name__ == '__main__': pytest.main(['-s','pytest-demo.py'])
命令执行:pytest -vv -m smoke
main执行:pytest.main(['-s','./pytest-demo.py','-m','smoke'])