Chethan -
Here is how you would apply a timeout loop to the code you provided:

require 'test\unit'
require 'timeout'

class MyTest < Test::Unit::TestCase
  def test_sample_01
    begin
      Timeout::timeout(3) do
        require "testcase_01" # test cases
      end
    rescue Timeout::timeout
      puts "took too long"
    end
  end
  def test_sample_02
    begin
      Timeout::timeout(1) do
        require "testcase_02" # test cases
      end
    rescue Timeout::timeout
      puts "took too long"
    end
  end
end

Where testcase_01 and testcase_02 are in separate ruby files and both look
like this:
puts "I am the first testcase"
sleep 2

This is a pretty simple example, but it demonstrates the concept.  I have to
say though, this is probably the most un-elegant way of doing this.  I've
never actually require'd a testcase inside of Test::Unit to get it to run
but it does work.  Seems like an easier way of doing this would be to wrap
each test in it's own timeout at the method level.  If you did this, then
your "batch" file would just be a series of requires.

Consider the following:
In testcase_01.rb:
class MyTest < Test::Unit::TestCase
  def test_sample_01
    begin
      Timeout::timeout(3) do
        puts "I am the first testcase"
        sleep 2
      end
    rescue Timeout::timeout
      puts "took too long"
    end
  end
end

In testcase_02.rb:
class MyTest < Test::Unit::TestCase
  def test_sample_02
    begin
      Timeout::timeout(1) do
        puts "I am the first testcase"
        sleep 2
      end
    rescue Timeout::timeout
      puts "took too long"
    end
  end
end

Then, your batch file becomes:
require 'test\unit'
require 'timeout'
require 'testcase_01'
require 'testcase_02'

This is marginally better.  However, I'm noticing that I get an Error from
Test Unit in the second example, as opposed to a Failure, not sure what is
causing this...

However, I'm still not even sure this will solve your problem if you got a
modal pop-up box that froze your thread.  As I said earlier, I think you
will need to look at trying to address the pop ups per testcase.

Maybe somebody else has some other ideas.  Let me know if you have any
questions.

Alan

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To post to this group, send email to watir-general@googlegroups.com
Before posting, please read the following guidelines: 
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/watir-general
-~----------~----~----~----~------~----~------~--~---

Reply via email to