与全局配置pytest.ini配置文件结合使用(见配置文件章节)
例如 配置文件中设置
markers = #分成三类High/Normal,Low High: smoke test Normal: product test Low: full test cases分模块执行:
- Case中加装饰器 @pytest.mark.High
- 执行参数中 pytest -vs -m “High”
import pytest class TestCompany(): @pytest.mark.Normal #标记方法为Low def test_company3(self): print("this is company 3") @pytest.mark.Normal def test_company4(self): print("this is company 4")
#pytest.ini中设置
[pytest]
addopts = -vs -m "High or Normal or Low" #High Normal Low用or链接代表都执行