简体   繁体   English

如何查看黄瓜中每个方案步骤所使用的步骤定义

[英]How can I see which step definitions are used for each scenario step in cucumber

Is there any way to get cucumber to print out which step definitions are being used for each step in a scenario? 有什么方法可以让黄瓜打印出方案中每个步骤使用的步骤定义?

It would ideally print out each step as it follows it, along with the step definition used to interpret it. 理想情况下,它将打印出每个步骤,以及用于解释该步骤的步骤定义。

Eg. 例如。

$cucumber test.feature
"Given I am on the homepage" => test_steps.rb:1 "Given I am on #{capture_model}"

I just stumbled upon this question and don't know if you still need an answer. 我只是偶然发现了这个问题,不知道您是否还需要答案。 But There is a very simple way to get what you want. 但是有一种非常简单的方法来获取您想要的东西。

in your project in config you will find cucumber.yml there is a line defining your standard options. 在config的项目中,您会找到Cucumber.yml,该行定义了标准选项。 You should change the formatting to "pretty" in there to always get the fancy output or just run cucumber with -f "pretty". 您应该在那里将格式更改为“ pretty”,以始终获得精美的输出,或者仅使用-f“ pretty”运行黄瓜。

Here is the line I have in my cucumber.yml: 这是我的cucumber.yml中的行:

std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"

And this is the output you will get: 这是您将获得的输出:

 Scenario: Some scenario        # features/the_feature_its_in:line
    When I do something         # features/step_definitions/a_step_file.rb:12
    And I do another thing      # features/step_definitions/another_step_file.rb:180
    Then I validate something   # features/step_definitions/a_step_file.rb:25

The output will also be color coded and appear as they are run. 输出还将进行颜色编码,并在运行时显示。 Passing steps will be green. 通过步骤将为绿色。 Failing ones red and the failing ones will have the error message about the failure just following the step. 失败的指示灯为红色,失败的指示灯将在执行该步骤后显示有关失败的错误消息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM