Changing a variable when Ruby unit test fails -


i using ruby unit test in code below.

assert_equal(x, 'strin') 

i want change variable if test fails , test should still fail. how can that? did same in python using following code.

try:   self.assertequal(self.client.teststring(''), '') except assertionerror, e:   test_basetypes_fails = true   raise assertionerror( e.args ) 

the #assert_equal method in ruby's test/unit library raises test::unit::assertionfailederror or (minitest::assertion in ruby 1.9.3 or later) on failed assertions, so:

begin   assert_equal(x, 'strin') rescue test::unit::assertionfailederror   # whatever code   raise end 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -