gpt4 book ai didi

testing - 机器人框架 : exception handling

转载 作者:行者123 更新时间:2023-11-28 20:29:58 25 4
gpt4 key购买 nike

是否可以处理测试用例中的异常?我有 2 种故障要跟踪:测试运行失败,测试运行但收到错误输出。如果我需要引发异常以使我的测试失败,我如何区分这两种失败类型?所以说我有以下内容:

*** Test Cases ***
Case 1
Login 1.2.3.4 user pass
Check Log For this log line

如果我无法登录,则 Login 关键字会引发 ExecutionError。如果日志文件不存在,我还会得到一个 ExecutionError。但是如果日志文件确实存在并且该行不在日志中,我应该得到一个 OutputError

我可能想在 ExecutionError 上立即使测试失败,因为这意味着我的测试没有运行,并且环境或测试用例中存在一些需要修复的问题。但是在 OutputError 上,我可能想继续测试。它可能只涉及单个输出,测试可能对继续检查其余输出有值(value)。

如何做到这一点?

最佳答案

Robot有几个处理错误的关键字,比如Run keyword and ignore error可用于运行另一个可能会失败的关键字。来自文档:

This keyword returns two values, so that the first is either string PASS or FAIL, depending on the status of the executed keyword. The second value is either the return value of the keyword or the received error message. See Run Keyword And Return Status If you are only interested in the execution status.

话虽如此,编写调用您的登录关键字的基于 python 的关键字可能会更容易,因为处理多个异常会更容易。

关于testing - 机器人框架 : exception handling,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32510259/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com