From: Gavin Sinclair Date: 2002-11-05T20:39:01+09:00 Subject: Re: Debugging and Test::Unit - good news From: "Gavin Sinclair" > From: > > > > Hi, > > > > I often find I want to step through my test code > > with the debugger. But using Test::Unit and invoking > > the debugger as > > > > ruby -r debug example_test.rb > > > > and setting a breakpoint on the line I want to start > > debugging on don't work; the debugger simply > > finished without breaking. > > > > How can I deal with that? > > Good timing. I'm maintaing a list of debugger problems at > > http://www.rubygarden.org/ruby?RubyDebuggerProblems > > This is a known problem, and there's no (yet) known solution. This is probably > because Test::Unit relies on *at_exit* in order to actually run the tests, and > perhaps the debugger can't trap things from within at_exit. > > Maybe if you defined an explicit test runner within the Test::Unit framework > this problem would be avoided. I'll try this as well if it's possible. This works! At the bottom of my test file (say the test class is called TC_Foo), I placed the lines: require 'test/unit/ui/console/testrunner' Test::Unit::UI::Console::TestRunner.run(TC_Foo) This runs just the same as if you didn't have it, because the at_exit code would have run this anyway. I regard this as a workaround for now, because although it's not difficult, it's a minor hassle to do this when you want to debug. Note: TestUnit seems to run quite slowly under the debugger. However, the machine I'm running it on it slow anyway (even though it's a production server) so YMMV. Gavin