作为一名软件测试人员,我希望能够在测试执行过程中的任何阶段暂停使用want进行测试执行,以便调试失败的测试,并在演示过程中向客户展示更详细的特性。
Scenario: Pause suite mid demo, then resume
Given I am in a meeting to show off a new feature our team has developed
And a client asks us a question about the page we are currently on
When I press the 'p' key in the terminal
Then I should have enough time to answer the question in detail to the client
And I should be able to resume test execution by pressing the 'enter' key in the terminal
Scenario: Pause suite at a known point for debugging
Given there is a failed test
When I add the "pause" method to the step definition
Then the test should pause execution until pressing the 'enter' key in the terminal发布于 2017-10-03 19:28:01
这里的两个函数在Windows上工作,在大多数其他操作系统上也是如此。
# Checks for a pause command in the command line and if it has been pressed, will pause
def paused?
if STDIN.ready?
last_input = STDIN.gets
while last_input == 'p'
sleep 1
end
end
end
# Pauses for debugging, will continue when enter is pressed
def pause
print 'p'
last_input = STDIN.gets
while last_input == 'p'
sleep 1
end
end当在每个步骤定义的开始处放置一次时,第一个步骤提供了在完成步骤后通过在终端中按'p‘来直接暂停的能力。
或者,创建一个抽象库可能会产生更好的结果,因为可以在整个过程中使用paused?方法在执行过程中暂停其他点,而不是新步骤的开始。当按下'p‘以外的任何标准键时,这将恢复,但是我建议使用一个新行。
第二,只需暂停测试,直到按下任何键,此时,执行可以恢复--是调试的理想选择。
停下来愉快!
发布于 2017-10-03 20:41:27
您可以尝试使用AfterStep钩
AfterStep('@pauseable') do
answer = 'n'
begin
Timeout.timeout 1 do # wait for a second for user to press 'p'
answer = STDIN.getch
end
rescue Timeout::Error # answer is 'n' when no key is pressed during 1 second
end
STDIN.getch if answer == 'p' # wait until user presses any key
end现在,您可以将您的特性标记为@pauseable。运行它并按p暂停它。然后按任意键继续
https://stackoverflow.com/questions/46551978
复制相似问题