相关疑难解决方法(0)

使用pry-rescue来调试Cucumber步骤中的异常

我已经为我的Cucumber功能添加了一个Around钩子,我曾希望在抛出异常时让pry-rescue启动pry:

Around do |scenario, block|
  Pry::rescue do
    block.call
  end
end
Run Code Online (Sandbox Code Playgroud)

肯定会调用Around钩子,但步骤中抛出的异常不会被拯救.例如这一步:

When(/^I perform the action$/) do
  raise 'hell'
end
Run Code Online (Sandbox Code Playgroud)

...导致该功能失败,但不会让我在控制台撬到它.

是否有可能使用黄瓜撬救?我也提出这个问题,因为我怀疑它可能是一个错误.

更新:根据AdamT在评论中的建议,我:

  • @allow-rescue标签添加到调用故意破坏步骤的功能部件中
  • 添加puts日志记录以验证Around是否正在调用挂钩

当异常被提出时,它仍然无法进入pry,但我可以从puts语句中看到它正在进入Around钩子.

ruby cucumber pry

7
推荐指数
1
解决办法
2644
查看次数

标签 统计

cucumber ×1

pry ×1

ruby ×1