絕大多數集成/系統測試框架都支持失敗重運行的執行策略,從實現上來說,大概分爲2類:html
好比TestNG框架支持上述兩種執行策略,pytest框架經過rerunfailures插件支持第1種執行策略。RF的rerunfailed參數支持第2種執行策略shell
RF的rerunfailed能夠從第一次跑過的結果中,篩選出失敗的用例從新執行,結合rebot的--merge功能,能夠從新輸出output.xml,在Jenkins上展現出最後的測試結果。windows
\> pybot -R --rerunfailed output Select failed tests from an earlier output file to be re-executed. Equivalent to selecting same tests individually using --test option. \> rebot -R --merge When combining results, merge outputs together instead of putting them under a new top level suite. Example: rebot --merge orig.xml rerun.xml
Linux下shell腳本rfrerunbash
#!/bin/bash rm -f output/output.xml rm -f output/rerun.xml rm -f output/first_run_log.html rm -f output/second_run_log.html echo echo "#######################################" echo "# First Run #" echo "#######################################" echo pybot --outputdir output $@ # Stop the script here if all the tests were OK if [ $? -eq 0 ]; then exit 0 fi # backup the first log file cp output/log.html output/first_run_log.html echo echo "#######################################" echo "# Rerun Failed Tests #" echo "#######################################" echo pybot --outputdir output --nostatusrc --rerunfailed output/output.xml --output rerun.xml $@ # backup the second log file cp output/log.html output/second_run_log.html echo echo "########################" echo "# Merge output files #" echo "########################" echo rebot --nostatusrc --outputdir output --output output.xml --merge output/output.xml output/rerun.xml # Robot Framework generates a new output.xml
使用方式:框架
在log日誌中,第一次失敗的用例會顯示2條message測試