At work we're trying to better organize our system of tests. We are leaning towards Test::Class and spent all of yesterday writing tests using Test::Class. Any approach to testing has its strengths and weaknesses. One of the weaknesses we identified with Test::Class is its reluctance to play nicely with the perl debugger.

Some of us would like the have the ability to set a breakpoint at the beginning of a test method and step through the test in the debugger. Going about this in the normal way of starting the program, setting the breakpoint, and letting the debugger continue until the breakpoint is reached does not seem to work.

Sample test class:

package A; use strict; use warnings; use base 'Test::Class'; use Test::More; sub test_foo :Test(no_plan) { pass('foo'); } 1;

Debugger session (slightly abridged):

~$ perl -d -MA -e 'Test::Class->runtests' Loading DB routines from perl5db.pl version 1.28 Attribute::Handlers::CODE(0x82d4198)(/usr/lib/perl5/5.8.7/Attribute/Ha +ndlers.pm:206): 206: $global_phase++; DB<1> b A::test_foo DB<2> c ok 1 - foo 1..1 Debugged program terminated. DB<2> q ~$

So after setting the breakpoint and continuing, the debugger executes test_foo and the program ends before the debugger prompt returns. One way to force the debugger to stop at the beginning of the subroutine is to insert a $DB::single=1 into the code where the breakpoint would be.

I'm looking for ways to add breakpoints without modifying the code in a way that is as close as possible to how people already use the debugger. I'll update this post if I find any.


In reply to Using debugger breakpoints in Test::Class code by secondturtle

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.