champ12
champ12

Reputation: 59

Get Status from Scenario with Cucumber 2.0.0

It looks like its no longer possible use

scenario.status 

in Cucumber 2.0.0 to determine the status of a scenario (passed, failed, undefined, skipped). It looks like it is possible to see if a scenario either passes or fails, but I'm also looking to see when steps are undefined or skipped.

Previously, in my code I would write the results to a DB in the After hook of the scenario, like so:

After do |scenario|
  @controller.post_results(scenario)
end

Inside of post results, I would call scenario.status to get the status.

Is this no longer possible to do with Cucumber 2.0.0? If it is, what is the new method?

Upvotes: 1

Views: 2316

Answers (1)

Aravin
Aravin

Reputation: 7097

You need to use Hooks.rb to get the status of scenario.

You can use

if scenario.failed?
    todo...
end

or

scenario.status

inside the hooks.rb.

Find more details here: https://github.com/cucumber/cucumber/wiki/Hooks

Upvotes: 1

Related Questions