Cucumber 在给定的步骤后,钩子运行之前的黄瓜?

Cucumber 在给定的步骤后,钩子运行之前的黄瓜?,cucumber,Cucumber,当我在前钩子中运行某个对象时,它似乎发生在给定的第一步之后 Scenario: Stack Overflow Example Given some condition When something happens Then something should be Before do puts 'hello' end 产出: Scenario: Stack Overflow Example Given some condition Hello ....

当我在前钩子中运行某个对象时,它似乎发生在给定的第一步之后

Scenario: Stack Overflow Example
  Given some condition
  When something happens 
  Then something should be

Before do
  puts 'hello'
end
产出:

Scenario: Stack Overflow Example
  Given some condition
    Hello
    ....
每一步都会发生这种情况

这是我的误会还是黄瓜的特征?如何在给定步骤之前运行某个操作

非常感谢


R

我不知道技术原因,但cucumber在场景完成之前不会使用简单的“puts”语句打印


尝试STDOUT.puts“hello”,您将看到Before钩子首先运行。

或者您可以输出timestamp以查看事件发生的时间:timestemp=Time.new,然后放置timestemp.strftime(“%H:%M:%S.%L”)。