Pytest.main()函数之mark标签使用方法举例
1、创建.ini配置文件,定义标签
[pytest]# 固定的section名 markers= # 固定的option名称 smoking systems
2、创建用例,分别标记,举例如下:
import pytest
@pytest.mark.smoke
def test_a():
print('我是用例a')
def test_b():
print('我是用例b')
def test_c():
print('我是用例c')
3、创建执行所有用例的.py文件,如test_run_all.py
(-v 展示用例详细信息 -m仅执行指定标签的用例)
import pytest
if __name__ == '__main__':
pytest.main(['-v','-m smoke']) #-v 展示用例详细信息 -m仅执行指定标签的用例