为什么即使使用FailureHandling.CONTINUE_ON_FAILURE也会停止测试用例

时间:2019-07-03 09:06:30

标签: selenium error-handling katalon-studio

我不明白为什么我在呼叫者中使用 n1 n2 m p m p 0 2.0 1.0 4.0 3.0 1 NaN NaN 8.0 7.0 2 NaN NaN NaN NaN 却停止了测试用例。

输入呼叫者的代码

FailureHandling_CONTINUE_ON_FAILURE

被呼叫者出错:

此错误发生在用... switch (testCaseName) { case testCaseName: WebUI.callTestCase(findTestCase(testCaseName), param, FailureHandling.CONTINUE_ON_FAILURE) break } ... 调用的测试用例中

  

由以下原因引起:com.kms.katalon.core.webui.exception.WebElementNotFoundException:找不到ID为“ XXX”且位于“ By.xpath:XXX”的Web元素]

但是,如果我使用WebUI.callTestCase(...),被叫者必须停止,但呼叫者不是吗?

感谢帮助

1 个答案:

答案 0 :(得分:1)

我能够部分重现该问​​题。我编写了以下两个测试用例:

TC1:呼叫者

println ">>>> start caller"
if(!WebUI.callTestCase(findTestCase("Callee"), null, FailureHandling.OPTIONAL)){
    println ">>>> success!"
}
println ">>>> end caller"

TC2:被叫方

println ">>>> start callee"
assert 0

这是我的控制台输出,带有FailureHandling.OPTIONAL

2019-07-03 12:43:41.851 DEBUG testcase.Caller                          - 1: println(">>>> start caller")
>>>> start caller
2019-07-03 12:43:41.855 DEBUG testcase.Caller                          - 2: if (!(callTestCase(findTestCase("Callee"), null, OPTIONAL)))
2019-07-03 12:43:41.934 INFO  c.k.katalon.core.main.TestCaseExecutor   - --------------------
2019-07-03 12:43:41.934 INFO  c.k.katalon.core.main.TestCaseExecutor   - CALL Test Cases/Callee
2019-07-03 12:43:42.086 DEBUG testcase.Callee                          - 1: println(">>>> start callee")
>>>> start callee
2019-07-03 12:43:42.087 DEBUG testcase.Callee                          - 2: assert 0
2019-07-03 12:43:42.095 ERROR c.k.katalon.core.main.TestCaseExecutor   - ❌ Test Cases/Callee FAILED.
Reason:
Assertion failed: 

assert 0

    at Callee.run(Callee:18)
    at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
    ....

2019-07-03 12:43:42.104 INFO  c.k.katalon.core.main.TestCaseExecutor   - END CALL Test Cases/Callee
2019-07-03 12:43:42.104 INFO  c.k.katalon.core.main.TestCaseExecutor   - --------------------
2019-07-03 12:43:42.109 WARN  c.k.k.core.keyword.internal.KeywordMain  - Unable to call Test Case 'Test Cases/Callee' (Root cause: com.kms.katalon.core.exception.StepFailedException: Call Test Case 'Test Cases/Callee' failed
    at com.kms.katalon.core.keyword.builtin.CallTestCaseKeyword$_callTestCase_closure1.doCall(CallTestCaseKeyword.groovy:63)
    ....
Caused by: Assertion failed: 

assert 0

    at Callee.run(Callee:18)
    at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
    ...
)
2019-07-03 12:43:42.110 DEBUG testcase.Caller                          - 1: println(">>>> success!")
>>>> success!
2019-07-03 12:43:42.111 DEBUG testcase.Caller                          - 3: println(">>>> end caller")
>>>> end caller
2019-07-03 12:43:43.067 INFO  c.k.katalon.core.main.TestCaseExecutor   - END Test Cases/Caller

因此, TC2 失败,但是WebUI.callTestCase()抛出了一个异常,该异常在日志中被解释为WARN,因此传递了 TC1

当我切换到FailureHandling.CONTINUE_ON_FAILURE时,在日志中将其解释为ERROR,并且 TC1 TC2 均失败。有关失败处理here的更多信息。

我相信这是Katalon Studio中的错误。但是,我认为您可以使用FailureHandling.OPTIONAL作为获得所需结果的解决方法。