You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
require 'test/unit'
class FooBar < Test::Unit::TestCase
def test_raise_java_exception
exception_caught = false
begin
raise java.util.NoSuchElementException.new("Bad param")
rescue Java::JavaUtil::NoSuchElementException
exception_caught = true
end
assert exception_caught
end
def test_assert_raises_on_java_exception
assert_raises Java::JavaUtil::NoSuchElementException do
raise java.util.NoSuchElementException.new("Bad param")
end
end
def test_assert_raises_on_exception
assert_raises RuntimeError do
raise RuntimeError.new('error')
end
end
end
all tests passed for jruby 1.7
jruby 1.7.23 (1.9.3p551) 2015-11-24 f496dd5 on Java HotSpot(TM) 64-Bit Server VM 1.8.0_91-b14 +jit [darwin-x86_64]
but 9k gives an error on test_assert_raises_on_java_exception
jruby 9.1.2.0 (2.3.0) 2016-05-26 7357c8f Java HotSpot(TM) 64-Bit Server VM 25.91-b14 on 1.8.0_91-b14 +jit [darwin-x86_64]
Failure:
Should expect a class of exception, Java::JavaUtil::NoSuchElementException.
<nil> is not true.
test_assert_raises_on_java_exception(FooBar)
The text was updated successfully, but these errors were encountered:
oblutak
changed the title
test/unit assert_raises on java exception don't work on 9k
test/unit assert_raises on java exceptions doesn't work on 9k
Jun 1, 2016
on JRuby 1.7 you have the "built-in" test-unit (which used to be part of Ruby stdlib - also known as 1.x)
since Ruby 2.x you do have the test-unit gem bundled which is a successor of test-unit (started as 2.x) these days at version number 3.x ... safe to say that its a completely different piece of code. if you install test-unit gem on JRuby 1.7 (3.1 won't work but < 3.0 should) it might fail the same.
suggest you report this JRuby specific "regression" to test-unit itself - seems like (haven't looked) that its a simple arg validation - could be skipped or a condition (on JRuby) might be added checking whether arg.is_a?(java.lang.Throwable)
all tests passed for jruby 1.7
jruby 1.7.23 (1.9.3p551) 2015-11-24 f496dd5 on Java HotSpot(TM) 64-Bit Server VM 1.8.0_91-b14 +jit [darwin-x86_64]
but 9k gives an error on test_assert_raises_on_java_exception
The text was updated successfully, but these errors were encountered: