1

Calabash test hangs in between the scenarios when test run for long time, i was expecting scenario to timeout if any condition didn't met. however that also not happening so that test move on to next scenario.

Is there a way i can implement in my code to keep monitoring each scenario run time, so that it force scenario to fail if it takes a longer then expected, and afterwards next scenario runs normally ?

Any help highly appreciated!!

-mesh

Mesh
  • 193
  • 1
  • 7

2 Answers2

3

You can use an around hook, this one will timeout after 10 seconds:

Around do |scenario, block|
  Timeout.timeout(10) do
    block.call
  end
end
jmccure
  • 1,180
  • 7
  • 16
  • have you tried this ?, because this Around hook didn't give me same result for all scenario. Some time it does timeout and sometime not. – Mesh Mar 01 '15 at 15:21
  • Hmm could it be that the tests have background steps? http://makandracards.com/makandra/12039-cucumber-pitfall-around-does-not-apply-to-your-background-steps – jmccure Mar 01 '15 at 19:15
  • I have had inconsistent results with Around hooks and calabash. I traced the problem back to cucumber itself. After looking at the relevant issues, I concluded that hooks would be re-worked in cucumber 2.0. We are evaluating calabash + cucumber 2.0 compatibility. Please don't ask when we will add cucumber 2.0 support. It will depend on when cucumber 2.0 is released; something we have no control over. – jmoody Mar 02 '15 at 18:27
1

You can use this syntax to force step to fail

Syntax

fail(msg = 'Error. Check log for details.', options = {:prefix => nil, :name => nil, :label => nil})

Example

fail(msg ="Failed due to timeout")

In your case

Given (/^I do this$/)do 
  do some...
  sleep 10
  fail(msg="failure message")
end
Aravin
  • 6,605
  • 5
  • 42
  • 58