本文介绍了我怎么能知道刚刚在黄瓜的AfterStep钩子执行了哪个步骤?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在为Cucumber的 AfterStep
回调编写一个方法。
https://github.com/cucumber/cucumber/wiki/Hooks#step-hooks
如何知道在调用这个钩子之前执行的步骤?
解决方案
AfterStep
挂接只接收方案作为参数。
您可以做什么,计算步骤,然后获取当前的步骤:
AfterStep do | scenario |
pre>
@step || = 0
p scenario.steps [@step] .name
@step + = 1
end
这将依次打印每个参数的名称
I'm writing a method to be executed on the
AfterStep
callback for Cucumber.https://github.com/cucumber/cucumber/wiki/Hooks#step-hooks
How can I figure out which step was executed before this hook was called?
解决方案The
AfterStep
hook only receives the scenario as parameter.What you can do, is count the steps, and then get the current one:
AfterStep do |scenario| @step ||= 0 p scenario.steps[@step].name @step += 1 end
This will print, in turn, the names of each parameter
这篇关于我怎么能知道刚刚在黄瓜的AfterStep钩子执行了哪个步骤?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!