How to unit test for exception in threads

I need to unit test for the exception to be thrown in code like:

def test
  assert_raise Timeout::Error do
    Thread.new {
      raise  Timeout::Error
    }
  end
end

      

How to do it?

+2


a source to share


1 answer


in the assert_raise block:



t = Thread.new { raise Timeout::Error }
t.join

      

+1


a source







All Articles