Aleksi Niemel<aleksi.niemela / cinnober.com> writes: > > The later ones support > > > > assert_exception(Name) { code block } > > While we're on it I'd like to make another request. The new version of > RubyUnit-0.2.0 doesn't include this one yet. > > # 1.4142 would be enough in the first example > assert_equal_float( Math.sqrt(2), 1.41421, 4, "Approximation failed" ) > assert_equal_float( Math.sqrt(2), 1.4142135, 7, "Approximation failed" ) > assert_equal_float_rounded( Math.sqrt(2), 1.4142136, 7, "Approximation > failed" ) All our tests subclass TestCase with our own, which includes the method def assert_flequal(exp, actual, msg='') if exp == 0.0 error = 1e-7 else error = exp.abs/1e7 end assert((exp - actual).abs < error, "#{msg} Expected #{'%f' % exp} got #{'%f' % actual}") end > The other thing is to have some handling for subtests: reporting, > statistics. Last time I worked with RubyUnit the smallest unit of handling > was at test of the TestCase. It's pain in the ass if one's required to wrap > asserts into test_functions just to get proper reporting. > > def test_foo # real test > assert_equal(1,1) # subtest 1 > assert_equal(-1,-1) # subtest 2 > end Latest versions report the count of asserts executed.