Debugging in Test::Unit::TestCases

Hi,

This is no biggie but just wanted to points out
a difference between RUnit and Test::Unit that I find a bit annoying

In the latter I can’t seem to do

ruby -r debug test_case.rb

then set a breakpoint in a test method in a TestCase in test_case.rb and
the let it run up to the breakpoint. If I don’t remember incorrectly
RUnit had no troubles with this?

Or have I missed something?

Its no biggie but just wanted to point that out.

Thanks to Nathaniel and others working on unit testing frameworks,

Robert Feldt

ruby -r debug test_case.rb

Which version ?

pigeon% ruby -v -rdebug b.rb
ruby 1.8.0 (2003-03-03) [i686-linux]
Debug.rb
Emacs support available.

b.rb:2:require 'test/unit'
(rdb:1) l
[-3, 6] in b.rb
   1
=> 2 require 'test/unit'
   3
   4 class A < Test::Unit::TestCase
   5 def test_aa
   6 puts "aa"
(rdb:1) b 6
Set breakpoint 1 at b.rb:6
(rdb:1) c
Loaded suite b
Started
Breakpoint 1, test_aa at b.rb:6
b.rb:6: puts "aa"
(rdb:1) c
aa
.
Finished in 1.95283 seconds.

1 tests, 0 assertions, 0 failures, 0 errors
pigeon%

Guy Decoux

Yeah, its somewhat old

$ ruby -v
ruby 1.8.0 (2003-02-22) [i386-mingw32]

and second to latest Test::Unit. Hmm, seems I draw some erroneous
conclusions there, seems I can’t set any breakpoints at all. I thought it
had something to do with Test::Unit.

I’ll update to latest versions and see if that’ll fix it.

Thanks,

Robert

···

On Sat, 8 Mar 2003, ts wrote:

ruby -r debug test_case.rb

Which version ?

and second to latest Test::Unit. Hmm, seems I draw some erroneous
conclusions there, seems I can't set any breakpoints at all. I thought it
had something to do with Test::Unit.

Well, I've this in unit.rb

at_exit {
  # We can't debug tests run with at_exit unless we add the following:
  set_trace_func DEBUGGER__.context.method(:trace_func).to_proc if (defined? DEBUGGER__)

Guy Decoux

I don’t use at_exit in this one but it still doesn’t work

$ ruby -v
ruby 1.8.0 (2003-03-07) [i386-mingw32]

feldt@KLABADA /tmp/development/aardappel/trunk
$ ruby -r debug -Ilib test/test_tree.rb
Debug.rb
Emacs support available.

test/test_tree.rb:1:require ‘test/unit’
(rdb:1) b 67
Set breakpoint 1 at test_tree.rb:67
(rdb:1) c
Loaded suite test/test_tree
Started

Finished in 0.735 seconds.
6 tests, 27 assertions, 0 failures, 0 errors

Regards,

Robert Feldt

···

On Sat, 8 Mar 2003, ts wrote:

and second to latest Test::Unit. Hmm, seems I draw some erroneous
conclusions there, seems I can’t set any breakpoints at all. I thought it
had something to do with Test::Unit.

Well, I’ve this in unit.rb

at_exit {

We can’t debug tests run with at_exit unless we add the following:

set_trace_func DEBUGGER__.context.method(:trace_func).to_proc if (defined? DEBUGGER__)

I don't use at_exit in this one but it still doesn't work

Test::Unit *use* at_exit

Guy Decoux