首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >resume :暂停套件演示和调试,并具有恢复功能

resume :暂停套件演示和调试,并具有恢复功能
EN

Stack Overflow用户
提问于 2017-10-03 19:28:01
回答 2查看 296关注 0票数 0

作为一名软件测试人员,我希望能够在测试执行过程中的任何阶段暂停使用want进行测试执行,以便调试失败的测试,并在演示过程中向客户展示更详细的特性。

代码语言:javascript
复制
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
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-10-03 19:28:01

这里的两个函数在Windows上工作,在大多数其他操作系统上也是如此。

代码语言:javascript
复制
# 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‘以外的任何标准键时,这将恢复,但是我建议使用一个新行。

第二,只需暂停测试,直到按下任何键,此时,执行可以恢复--是调试的理想选择。

停下来愉快!

票数 1
EN

Stack Overflow用户

发布于 2017-10-03 20:41:27

您可以尝试使用AfterStep钩

代码语言:javascript
复制
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暂停它。然后按任意键继续

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46551978

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档