为什么 Cucumber 钩子方法不是小写?

发布于 2024-08-12 05:27:54 字数 117 浏览 4 评论 0原文

Cucumber 有几种不同的钩子方法,例如 Before、After 或 AfterStep。

我想知道 - 为什么这些方法名称不遵循 Ruby 的命名约定,将方法名称全部小写?

谢谢。

Cucumber has a few different hook methods like Before, After or AfterStep.

I was wondering - why doesn't these method names follow Ruby's naming conventions to write method names all lowercase?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

凤舞天涯 2024-08-19 05:27:54
  1. BeforeAfterAfterStepWorld 等 Ruby 挂钩都是大写的,因为 Given、WhenThen Ruby 挂钩为大写。
  2. GivenWhenThen Ruby 挂钩是大写的,因为 GivenWhen , Then Gherkin 关键字是大写的。
  3. GivenWhenThen Gherkin 关键字均为大写,因为 Gherkin 语言旨在与 BDD 用户故事
  1. The Before, After, AfterStep, World etc. Ruby hooks are uppercase because the Given, When, Then Ruby hooks are uppercase.
  2. The Given, When, Then Ruby hooks are uppercase because the Given, When, Then Gherkin keywords are uppercase.
  3. The Given, When, Then Gherkin keywords are uppercase because the Gherkin language is intended to match the standard template for BDD User Stories.
剩余の解释 2024-08-19 05:27:54

这只是我的猜测,但我猜钩子方法的名称是驼峰式的,以匹配 ThenWhenGiven 方法,这些方法用于定义步骤:

Then "I should be served coffee" do
  @machine.dispensed_drink.should == "coffee"
end

步骤定义方法的名称依次采用驼峰式命名,以匹配场景的外观:

Scenario: Buy last coffee
  Given there are 1 coffees left in the machine
  And I have deposited 1$
  When I press the coffee button
  Then I should be served a coffee

This is merely speculation on my part but I guess the hook methods' names are camel-cased to match Then, When, and Given methods which are used to define steps:

Then "I should be served coffee" do
  @machine.dispensed_drink.should == "coffee"
end

Step definition methods' names are in turn camel-cased to match the way scenarios look:

Scenario: Buy last coffee
  Given there are 1 coffees left in the machine
  And I have deposited 1$
  When I press the coffee button
  Then I should be served a coffee
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文