Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do I not see the thrown exceptions in a Cucumber "Around"?

Tags:

ruby

cucumber

I have a set of cucumber tests that get run on a build server.

I often want faster feedback than the server directly provides and so I watch the console output as it runs. I was wanting a way of identifying any failing test with a single search term so I modified our Around to print "Failed Test" on any exception, but Ruby doesn't seem to be handing the exception back up to the around. I've verified this by having puts statements after the begin ... end.

Does anyone know why this is happening or a way of wrapping any exception thrown from a failing test in a begin?

Around() do |scenario, block|
  begin
    Timeout.timeout(0.1) do
      block.call
    end
  rescue Timeout::Error => e
    puts "Failed Test"
    puts caller
  rescue Exception => e
    puts "Failed Test"
    raise e
  end
end
like image 354
Chris Atkinson Avatar asked Nov 26 '22 06:11

Chris Atkinson


1 Answers

Looking at cucumber 1.3.12 it actually rescues any exceptions from scenario steps. So you can't see them in any way without modifying cucumber gem.

See my answer on how to put a debug hook in that place for more information: https://stackoverflow.com/a/22654786/520567

like image 83
akostadinov Avatar answered Dec 21 '22 14:12

akostadinov