pytest-repeat插件,指定用例重復運行、重復運行次數


pytest-repeat是pytest的插件:(pytest-repeat 無法支持使用unittest.TestCase測試類)

作用:
用於重復執行單個用例,或多個測試用例,並指定重復次數,
安裝:
pip install pytest-repeat
使用:
--count命令,指定要運行測試用例和測試次數:pytest --count=10 test_demo.py

 

注:
--repeat-scope類似於 @pytest fixture()的scope參數,
--repeat-scope也可設置參數: 默認的function、module、session 、class
使用:pytest test_demo.py   -s   --count=5  --repeat-scope=session

另:
結合使用mark標記來重復執行:
@pytest.mark.repeat(count)

使用:@pytest.mark.repeat(3) #在要重復執行的case上加上這個裝飾器即可,運行時會默認運行指定次數3


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM