绝大多数集成/系统测试框架都支持失败重运行的执行策略,从实现上来说,大概分为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测试