【发布时间】:2021-03-22 13:06:26
【问题描述】:
如果单个特定测试用例失败,有没有办法重新运行整个测试套件。
例如,一个包含测试用例的机器人代码将检查 cookie 值,如果 cookie 具有特定模式,则将继续执行其余代码,如果失败,则应重新运行整个机器人代码/测试Suite 并重复此操作 3 次,如果 cookie 值在 3 次运行中不相同,则让它完全通过测试套件。
【问题讨论】:
如果单个特定测试用例失败,有没有办法重新运行整个测试套件。
例如,一个包含测试用例的机器人代码将检查 cookie 值,如果 cookie 具有特定模式,则将继续执行其余代码,如果失败,则应重新运行整个机器人代码/测试Suite 并重复此操作 3 次,如果 cookie 值在 3 次运行中不相同,则让它完全通过测试套件。
【问题讨论】:
您可以运行原始测试、重新运行失败并合并两次运行的结果。如果某些测试在第一次运行时失败,然后在第二次运行中通过,您会在结果中看到。
通常需要重新执行一部分测试,例如, 在修复被测系统或测试中的错误之后 他们自己。这可以通过按名称选择测试用例来完成 (--test 和 --suite 选项),标签(--include 和 --exclude),或通过 以前的状态(--rerunfailed 或--rerunfailedsuites)。
robot --output original.xml tests # first execute all tests
robot --rerunfailedsuites original.xml --output rerun.xml tests # then re-execute failing
rebot --merge original.xml rerun.xml # finally merge results
你可以在这里https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#merging-re-executed-tests阅读更多相关信息
对于您的具体示例,我不确定您是否可以这样做。但是您可以保存运行的退出代码并据此评估它
robot "your robot options" $@
if [ $? -eq 0 ]; then
"evaluation options when passed"
fi
else
"evaluation options when failed"
fi
【讨论】: