一、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,群里发放的免费资料都是笔者十多年测试生涯的精华。还有同行大神一起交流技术哦。
作者:来自公众号:软测之家
出处:https://www.cnblogs.com/csmashang/p/12603875.html
原创不易,欢迎转载,但未经作者同意请保留此段声明,并在文章页面明显位置给出原文链接。