入门8-Pytest.mark装饰器设置用例分组执行

与全局配置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链接代表都执行

 

 

posted @ 2023-05-09 22:08  蜗牛果果  阅读(31)  评论(0编辑  收藏  举报