前言:
    当你的用例特别多的时候,又想分模块执行用例的时候,有没有办法呢,pytest.mark,相当于给每个用例打上”标签”,执行用例的时候根据所需执行某个模块的用例

    语法:pytest.mark.tag
    例如 pytest.mark.channel,执行的时候使用命令 pytest -m=channel,即只执行被标记了channel标签的用例,当执行用例的时候出现如下提示:
    image.png
    原因是因为我们没有在pytest的配置文件”注册”这个标记,只需要在项目的根目录新建pytest.ini文件,更多关于pytest.ini详见pytest.ini配置文件详解,”注册”该标记
    格式:
    [pytest] # 固定的section名
    markers= # 固定的option名称
      标签名1: 标签名的说明内容。
      标签名2
      标签名N

    1. # pytest.ini文件
    2. [pytest]
    3. markers=
    4. channel: this is channel