Diro's Journey

Programming Cooking Music Photography




平常在使用 Robot Framework 時,通常會搭配 RIDE 來撰寫,整體而言算是個有幫助的 IDE 功具。有時侯在開發 UAT 時,會希望一但有錯誤就馬上停止執行,這樣可以馬上就定位到有問題的地方(keyword)。

在 RIDE 中有一個 Pause On Failure 的功能,如字面所述,就是一旦有失敗,它就會進入暫停的狀態,但這個功能最大的問題就是:'Pause On Failure' should ignore the keyword failure when using 'Wait Until Keyword Succeeds' 。
細節可以參考:https://github.com/robotframework/ride/issues/1259

像我們的 UAT 當中,有一個叫 Wait Property 的 keyword,會等待某個屬性值變成我們期望的值,但因為它裡頭是用 Wait Until Keyword Succeeds 實作,因此一但進入 等待 狀態時,就會變成 Pause 了。因此,我幫 RIDE 進行了一個小手術,讓它在 Wait Until Keyword Succeeds 之後會暫時 ignore Failure,讓 Wait Property 可以順利執行。

關鍵點在 TestRunnerAgent.py 裡頭的 start_keyword 及 end_keyword,可參考下面的 diff:

diff --git a/src/robotide/contrib/testrunner/TestRunnerAgent.py b/src/robotide/contrib/testrunner/TestRunnerAgent.py
index 1d1b0f7..eee9806 100644
--- a/src/robotide/contrib/testrunner/TestRunnerAgent.py
+++ b/src/robotide/contrib/testrunner/TestRunnerAgent.py
@@ -112,6 +112,8 @@ class TestRunnerAgent:
         self._send_pid()
         self._create_debugger((len(args)>=2) and (args[1] == 'True'))
         self._create_kill_server()
+        self.ignorePausedOnFail = False
+        self.nestedLevel = 0

     def _create_debugger(self, pause_on_failure):
         self._debugger = RobotDebugger(pause_on_failure)
@@ -143,6 +145,13 @@ class TestRunnerAgent:
         self._send_socket("end_suite", name, attrs)

     def start_keyword(self, name, attrs):
+        self.nestedLevel += 1
+        if attrs['kwname'] == 'Wait Until Keyword Succeeds':
+             self.ignorePausedOnFail = True
+        if self.nestedLevel <= 2:
+            print "[KEYWORD]" + " "*self.nestedLevel + attrs['kwname']
+        sys.stdout.flush()
+
         self._send_socket("start_keyword", name, attrs)
         if self._debugger.is_breakpoint(name, attrs):
             self._debugger.pause()
@@ -154,8 +163,14 @@ class TestRunnerAgent:
             self._send_socket('continue')

     def end_keyword(self, name, attrs):
+        self.nestedLevel -= 1
+        if self.ignorePausedOnFail == True:
+            attrs['status'] = 'PASS'
         self._send_socket("end_keyword", name, attrs)
         self._debugger.end_keyword(attrs['status']=='PASS')
+        if attrs['kwname'] == 'Wait Until Keyword Succeeds':
+             self.ignorePausedOnFail = False
+



Older Posts Home

ABOUT AUTHOR

Follow us

POPULAR POSTS

  • QML + Arduino / Web + Arduino
  • QML + LeapMotion & Arduino
  • [SOFT] TeamCity - 好用的 Continuous Integration 持續整合工具
  • How to Integrate Robot Framework with TestRail
  • [DECO] Eva Solo 花盆

Categories

  • 2016 5
  • agile 3
  • Bike 4
  • Book 4
  • Cooking 1
  • DECO3 4
  • House 8
  • Interior Design 4
  • IoT 1
  • IT 7
  • Life 13
  • Photography 1
  • Programming 22
  • QML 8
  • Qt 9
  • Scrum 3
  • Software 19
  • Travel 9
  • UAT 1
  • Uncategoried 3
  • 喇叭 1
  • 裝潢 6

FOLLOW US @ INSTAGRAM

About Me

Popular Posts

  • Odd-e LeSS@上海 後記 Part 4
    在 LeSS 最後一天,聽到別的公司在導入敏捷時,也成立了很多很多的實踐社群 CoP (Community of Practice),其中一個是 心靈成長 CoP,讓我印象非常深刻,這邊來聊聊為什麼 :) 在第五項修練中,彼得聖吉一直在強調"整體": 「遠古的人類並...
  • 單車路線#5 - 大坑缺溪-秀才窩自行車道-梅崗
    沿大坑 缺 溪騎到鎮南橋後,直走接往中庸路,經過一小段爬坡即接往福羚路,再往接瑞溪路即可抵達楊梅愛買後方,接著往裕成路(五楊高架下方)是我騎到楊梅最喜歡的路線。裕成路到底後,便到達楊梅校前路,是熱門的自行車路線,校前路前行便會抵達這條路線的重點-秀才窩自行車道,這個路線會穿過小茶...

Advertisement

Copyright © 2016 Diro's Journey. Created by OddThemes