calabash / calabash-ios

Calabash for iOS
Other
1.81k stars 369 forks source link

Resume with next scenario on fail (feature request) #1314

Closed micdahl closed 7 years ago

micdahl commented 7 years ago

I think it would be nice, if there was an environment variable like RESUME_ON_FAILURE, which would allow to prevent calabash from stopping at the first failing scenario and resume with the next scenarios. So the user would have a list of all failing scenarios after the complete calabash run and would not only see the first failing one.

jmoody commented 7 years ago

You can control this in your After hook.

I think the default behavior is not to stop executing?

Can you show your After hook?

micdahl commented 7 years ago

Looks like you are right. Thank you for giving the advice, where to look. I had copied the content of my 01_launch.rb (Initialization is done here) from elsewhere. Current after hook for scenarios is as follows:

After do |scenario|
  case :debug
    when :debug
      Calabash::Launchctl.instance.maybe_exit_cucumber_on_failure(scenario, self)
    when :pry
      Calabash::Launchctl.instance.maybe_pry_on_failure(scenario, self)
    else
      RunLoop.log_error("Unknown action in After hook")
      Calabash::Launchctl.instance.maybe_exit_cucumber_on_failure(scenario, self)
  end
end

where maybe_exit_cucumber_on_failure is defined:

    def maybe_exit_cucumber_on_failure(scenario, world)
      if scenario.failed?
        if RunLoop::Environment.xtc?
          shutdown(world)
          sleep(1.0)
        else
          exit!(1)
        end
      end
    end

So clearing the after hook should do what I want. I will try in the next days and update. Thank you!

Update: Just tested and works fine!