After each scenario I would like to list all steps of this scenario. There is any way to do that?
Asked
Active
Viewed 1,157 times
2 Answers
1
You can use Scenario Hooks to get steps for each scenario:
After do |scenario|
scenario.steps.each { |s| puts s.to_sexp }
end

hidro
- 12,333
- 6
- 53
- 53
-
That's sort of what I need. How to convert steps from objects to readable strings? – Kirill Feb 28 '15 at 11:45
-
Use `step.to_sexp`, then modify output to what you want, check my edit. Please accept my answer if it helps you thanks! – hidro Feb 28 '15 at 11:47
-
Yeah, I tried to_sexp and output is huge. It includes all possible information about the steps, I suppose. – Kirill Feb 28 '15 at 11:50
-
Well, if that's the case you may want to check `Cucumber::Ast::StepInvocation` class to see what's available for you. – hidro Feb 28 '15 at 11:52
0
If a report of executed scenarios is what you are after then simply set one of many types of reports formats (html, json etc) that you can specify in your CukesRunner class
See example bellow:
@RunWith(Cucumber.class)
@CucumberOptions(format = { "pretty", "html:target/cucumber-html-report", "json:target/cucumber-json-report.json" })
public class CukesRunner {
}

DaddyMoe
- 990
- 1
- 14
- 20
-
-
1`cucumber features/feature_name.feature -f pretty` this has already been asked and answered here http://stackoverflow.com/questions/25781478/test-report-output-using-cucumber-selenium-ruby – DaddyMoe Feb 28 '15 at 21:59
-
That's not it. I don't need to print steps. I just need to get them in after hook and do some work. – Kirill Feb 28 '15 at 22:01