gestión de etiquetas pytest

gestión de etiquetas pytest

Crear archivo pytest.ini

El contenido es el siguiente:

[pytest]

markers =
    login: 登录测试
    smoke: 冒烟测试

En el caso de uso:

class TestHome(object):

    @staticmethod
    @pytest.mark.smoke
    @pytest.mark.parametrize("k, li_str", [[2, ['68', '11', '2', '3', '23']], [3, ['68', '11', '2', '3', '23', '68']]])
    def test_01(k, li_str) -> None:

Operación de comando de terminal:

if __name__ == '__main__':

    # python -m pytest test_pytest.py -k 03  执行test_03用例
    # python -m pytest test_pytest.py -s     输出print

    # python -m pytest - m “p1 or p2”  # 运行有p1标识或p2标识用例
    # python -m pytest - m “p1 and p2”  # 运行有p1和p2标识的用例
    # python -m pytest - m “not p1”  # 运行除了p1之外的标识的用例
    # python -m pytest - m “p1 and not p2”  # 运行有p1和没有p2标识的用例
    # 注意:-m后面不能带’ '号(单引号),只能带" "(双引号),不然识别不到

 

Supongo que te gusta

Origin blog.csdn.net/chuancheng_zeng/article/details/115243828
Recomendado
Clasificación