简体   繁体   中英

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. You should change the formatting to "pretty" in there to always get the fancy output or just run cucumber with -f "pretty".

Here is the line I have in my 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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