http://testunit.talbott.ws/ Supersedes both R''''''ubyUnit and R''''''ubyLapidary. Essentially, a matured Lapidary with an optional R''''''ubyUnit compatibility layer. Included in Ruby 1.8 and higher. ---- Get your Ruby TestCollector while it's hot! ---- ''Moved from R''''''ubyUnit...'' A simple guide for getting started is available at http://www.tech.dmu.ac.uk/~hgs/ruby/ruby-unit.html ---- ''Also moved from R''''''ubyUnit...'' Ruby is a great language for testing with MockObject''''''s. Because you can define new methods for individual objects, you can easily mock up an object that checks that your tested object observes the preconditions of the objects it interacts with. Something like this: # Assuming that the object to test has been created in the setup method # and is called @tested # def test_something mock = Object.new # create a mock object mock.extend( RUNIT::Assert ) # pull in the assertion definitions def mock.method_called_by_testee( arg1, arg2 ) # define a mocked method assert_equals( some_value, arg1 ) assert_not_nil( arg2 ) # etc return expected_result end @tested.do_something_with( mock ) # assert postconditions and invariants end -- NatPryce ---- The Test::Unit variant of the above # Assuming that the object to test has been created in the setup method # and is called @tested # def test_something mock = Object.new # create a mock object mock.extend( Test::Unit::Assert ) # pull in the assertion definitions def mock.method_called_by_testee( arg1, arg2 ) # define a mocked method assert_equals( some_value, arg1 ) assert_not_nil( arg2 ) # etc return expected_result end @tested.do_something_with( mock ) # assert postconditions and invariants end ---- ''Ohh I was looking for this example all over the web. I knew I've seen it somewhere, but couldn't remember where. - Actually what I wanted is some kind of 'thing' where I don't have to pass my MockObject into the Objects and pass it around only to block the call onto another system and track the calling. I'm using MockObject''''''s mainly to test and block the calls to other systems, like a telnet or db connection. Now I have to pass my Telnet MockObject every time into the code to have it passed around only to make sure that my calls are getting blocked and I can track what happened. What would be a nice solution here? I add this page to CategoryMockObjects as well, so I'll find it next time much faster... :-) -- DanielFlueck'' ---- CategoryRuby