一、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'])
独行踽近,众行致远!欢迎加入《软件测试技术交流群:695458161》各种软件测试技术,自动化框架,单元测试框架,数据驱动框架,持续集成jenkins应有尽有!
作者:诸葛
出处:https://blog.csdn.net/pengjiangchun
欢迎转载,但未经作者同意请保留此段声明,并在文章页面明显位置给出原文链接。