【发布时间】:2021-09-24 11:47:35
【问题描述】:
我们在带有 Python 3.8.7 的 Windows 10 上使用 Squish for Qt 6.6.2,并使用带有 Robot Framework 4.0.1 的 squishtest 模块运行我们的测试。
我们在使用 Squish API 提供的 test 函数时遇到问题,使用此类调用完成的任何验证(例如 squishtest.test.imagePresent)都将通过。问题本身很容易确定,尽管验证失败,但函数调用本身正在通过而没有引发异常。这也可以从 squishrunner 提供的报告中得到验证,其中我们有 <scriptedVerificationResult type="FAIL" time="--"> 已通过的执行。
问题是,我们能否以任何方式将实际验证结果传递给机器人,以便相应地使测试失败?最好实时进行,而不是事后解析报告。
在 Squish 中这工作得非常好
def main():
startApplication("AUT")
snooze(2)
test.imagePresent("image.png", {"tolerant": True, "threshold": 85},
waitForObjectExists(names.sceneContainer_GraphWidget))
但是对于机器人,这总是通过
# In testSuite.robot
*** Settings ***
Library MySquishLib
*** Test Cases ***
Test Image
Start AUT
Verify Image image.png {"tolerant": True, "threshold": 85} names.sceneContainer_GraphWidget
# In MySquishLib.py
import squishtest
import names
def start_aut():
squishtest.startApplication("AUT")
def verify_image(imageFile, imageParams, imageArea):
squishtest.test.imagePresent(imageFile, imageParams, imageArea)
【问题讨论】:
-
test.imagePresent() 未记录为引发错误。对我来说,您的低容差阈值会导致“找到”地址簿主窗口,即使它实际上不在屏幕上。使用 squishtest 模块时无法重现该问题。 test.imagePresent() 按我的预期返回 true 或 false。在没有 Robot 框架的情况下使用 squishtest 时,你能重现这个问题吗?
-
我的措辞可能有点不清楚,但这正是这个问题的重点。我希望函数调用 A)返回 VP 的状态或 B)在失败的 VP 上抛出错误。起初,我预计容差也会成为问题,但如前所述,在 Squish 创建的
results.xml中,VP 已按预期通过/失败。 -
@frog.ca “问题”实际上在于,正如您从问题中看到的那样,我实际上并没有在任何地方使用返回值。正如您所指出的 - 该函数确实正确返回 bool 值,并且不应该引发异常。此外,可以在运行时从
results.xml找到结果。如果使用xml3报告,则在测试结束之前已经可以访问这些值。