簡體   English   中英

機器人框架在失敗中停止拆卸執行

[英]robot framework stop teardown execution in failure

我正在使用機器人框架來測試我的應用程序

我在測試中使用了拆卸。

它按預期工作,如果我的測試結束或失敗,則拆卸開始執行。 當拆卸執行失敗時,我的問題就開始了,然后我希望它停止。

*** Test Cases ***
Test new data import
   Setup test case
   Run test case
   [Teardown]  TearDown test case

Teardown test case
   Insert name in filter
   Delete user

場景是“在過濾器中插入名稱”失敗時,我希望它停止運行,但它執行“刪除用戶”關鍵字。

可以預防嗎?

我終於做了一些研究,看看為什么使用 --exitonfailure (在其他答案中建議)對我不起作用,這是因為它錯過了拆解工作流程。

https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#id689可以停止拆卸執行

Teardown -> 即使它們的某些關鍵字失敗,它們也會被完全執行。

所以,我要解決的是使用 Run Keyword 並返回 Status 和 Run Keyword if 來解決:

*** Test Cases ***
Test new data import
  Setup test case
  Run test case
  [Teardown]  TearDown test case

Teardown test case
  ${filterStatus}  Run keyword and return status  Insert name in filter
  Run keyword if  ${filterStatus}  Delete user
  ... ELSE  fail  Filter filter by name failed

嘗試這樣做以防止在調用 exitonfailure 時執行“刪除用戶”關鍵字: http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#stopping-when-first-test-case-fails

用法:使用選項時,必須始終在運行腳本和數據源之間給出

--exitonfailure -x

示例: robot --exitonfailure 01_robot_test.robot

如果使用選項 --exitonfailure (-X),如果任何關鍵測試失敗,測試執行將立即停止。 剩余的測試被標記為失敗而沒有實際執行它們。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM