使用pip安裝pytest-repeat
pip install pytest -repeat
重復執行--count
命令行執行:pytest baidu/test_1_baidu.py -s --count=5
文件中寫參數執行
在代碼中標記要重復多次的測試
@pytest.mark.repeat(1000)
--repeat-scope
--repeat-scope類似於pytest fixture的scope參數,--repeat-scope也可以設置參數: session
, module
,class
或者function
(默認值)
function
(默認)范圍針對每個用例重復執行,再執行下一個用例class
以class為用例集合單位,重復執行class里面的用例,再執行下一個module
以模塊為單位,重復執行模塊里面的用例,再執行下一個session
重復整個測試會話,即所有收集的測試執行一次,然后所有這些測試再次執行等等
使用--repeat-scope=session
重復執行整個會話用例
如:pytest test_1_baidu.py -s --count=5 --repeat-scope=session