require 'test/unit' require 'test/unit/ui/console/testrunner' require 'test/unit/ui/testrunnermediator' require 'rapt/test_observer' # prevent the normal Test::Unit at_exit handler from running. Test::Unit.run = false module Test module Unit module UI module Console class TestRunner #-- # we need to grab a hold of the mediator for this test run, so # we can listen to test events. Since the default rake and test::unit # setups presume total control over the ruby environment when it's # running, we haev to... ahem, intervene slightly to get a handle # on the test results. This is the cleanest way. #++ private alias :old_attach_to_mediator :attach_to_mediator def attach_to_mediator(*args) old_attach_to_mediator(*args) RaPT::TestObserver.instance.attach_mediator(@mediator) end end end end end end # Our new at_exit handler, which will run all the test cases loaded # Unlike the default mechanism in test/unit, this handler will not # call exit again, allowing the rake task to continue working. at_exit do unless $! result = Test::Unit::AutoRunner.run end end