zoukankan      html  css  js  c++  java
  • pytest3-命令行选项

    1.pytest -h 查看pytest常用命令

    E:myprojpytest_demo>pytest -h
    usage: pytest [options] [file_or_dir] [file_or_dir] [...]
    
    positional arguments:
      file_or_dir
    
    general:
      -k EXPRESSION         only run tests which match the given substring
                            expression. An expression is a python evaluatable
                            expression where all names are substring-matched
    ...以下略

    2.pytest -vs(-v是啰嗦模式,啥信息都显示;-s允许测试运行时输出任何符合标准的输出流信息,例如代码里面的print)

    执行结果:
    E:myprojpytest_demo>pytest -vs
    ================================================================================== test session starts ==================================================================================
    platform win32 -- Python 3.6.5, pytest-5.1.2, py-1.8.0, pluggy-0.12.0 -- e:softpythonpython36python.exe
    cachedir: .pytest_cache
    rootdir: E:myprojpytest_demo, inifile: pytest.ini, testpaths: ./testcases
    collected 9 items                                                                                                                                                                        
    
    testcases/test_02.py::test_1 FAILED              # FAILED指测试失败
    testcases/test_02.py::test_2 b
    PASSED  # 指测试通过
    testcases/test_02.py::test_3 c
    PASSED
    testcases/test_fix.py::Test1::test_s1[u6d4bu8bd5-u6d4bu8bd5] 测试
    PASSED
    testcases/test_fix.py::Test1::test_s2 用例2:不需要登录,操作222
    PASSED
    testcases/test_fix.py::Test1::test_s3 登录系统
    用例3:登录之后其它动作333
    PASSED
    testcases/test_fix.py::Test2::test_s4 登录系统
    用例4:登录之后其它动作444
    PASSED
    testcases/test_fix.py::Test2::test_s5 用例5:不需要登录,操作555
    PASSED
    testcases/test_fix.py::Test2::test_s6 用例6:登录之后其它动作666
    PASSED
    
    ======================================================================================= FAILURES ========================================================================================
    ________________________________________________________________________________________ test_1 _________________________________________________________________________________________
    
        def test_1():
            a = 2
    >       assert a == 1
    E       assert 2 == 1
    E         -2
    E         +1
    
    testcases	est_02.py:9: AssertionError
    ============================================================================== 1 failed, 8 passed in 0.29s ==============================================================================

     3.pytest --lf --ff

    --lf, --last-failed rerun only the tests that failed at the last run (or          # 运行上次失败的用例,如果没有失败会重新跑
    all if none failed)
    --ff, --failed-first run all tests but run the last failures first. This
    may re-order tests and thus lead to repeated fixture
    setup/teardown

    4.pytest -x : exit instantly on first error or failed test

    5.pytest -q 简化输出信息

    6.pytest --tb=no 关闭错误信息回溯 argument --tb: (choose from 'short', 'no', 'line')

    7.pytest --markers :查看所有markers

    8.pytest -m “mark标记名”:运行指定标记的测试用例

    9.pytest -k

  • 相关阅读:
    mysql如何查询最新插入的数据
    nodejs express开发
    在线考试实现倒计时的代码
    centos的vsftp修改上传下载速度
    centos vsftpd
    ul和li里面的list-style
    算法竞赛入门经典 暴力求解法 7.1简单枚举 最大乘积
    算法竞赛入门经典 暴力求解法 7.1简单枚举 最大乘积
    算法竞赛入门经典 暴力求解法 7.1简单枚举 除法
    算法竞赛入门经典 暴力求解法 7.1简单枚举 除法
  • 原文地址:https://www.cnblogs.com/wang-mengmeng/p/11456544.html
Copyright © 2011-2022 走看看