美文网首页
pytest实现失败重新运行机制

pytest实现失败重新运行机制

作者: 成功在于实践 | 来源:发表于2020-08-09 12:32 被阅读0次
# test_002.py
import pytest

def test_001():
    print('我执行了1')
    assert 0==1
def test_002():
    print('我执行了2')
    assert 0==0
def test_003():
    print('我执行了3')
    assert 0==0
def test_004():
    print('我执行了4')
    assert 0==1
if __name__ == '__main__':
    pytest.main(['-s','test_002.py'])
 # --lf, --last - failed - 只重新运行上次失败的用例,如果没有失败则全部运行

# --ff, --failed - first - 先运行故障然后再运行其余的测试。
第一次执行:  pytest    --lf   test_002.py
image.png
第二次执行:  pytest    --lf   test_002.py
image.png

注意:清除之前的缓存

image.png
第一次执行:  pytest    --ff   test_002.py
image.png
第二次执行:  pytest    --ff   test_002.py
image.png

相关文章

网友评论

      本文标题:pytest实现失败重新运行机制

      本文链接:https://www.haomeiwen.com/subject/lpckdktx.html