Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^2: Get the number of the current test when debugging a test script

by Dumu (Monk)
on Jul 01, 2015 at 12:42 UTC ( [id://1132802]=note: print w/replies, xml ) Need Help??


in reply to Re: Get the number of the current test when debugging a test script
in thread Get the number of the current test when debugging a test script

So the answer seems to be that you can just create a reference to the $builder object at any time, either in your test script:

my $builder = Test::Most->builder;

or in the debugger ('my' doesn't seem to play well on the debugger command line):

NB for newbies: the DB<x> bit is the debugger prompt, not part of the code.
DB<x> $builder = Test::Most->builder;

If you do either of the above, you should find you can subsequently do either of the following in the debugger to print out the current (actually, the latest) test number:

DB<x> x $builder->{Curr_Test} DB<x> p $builder->{Curr_Test}

- or, as I originally sought to do, run the debugger and break after a particular test, e.g. test #20:

DB<x> w $builder->{Curr_Test} == 20 DB<x> c

Some Monks seem uncomfortable with the idea of running a test script through a debugger. I can sort of understand what you're saying, folks: a test script is effectively a static debugging service, so why run it through the debugger as well? I have a few answers to this but the simplest are:

"... Perl tests are just Perl code." -- chromatic, in Organizing Perl Test Files
"TIMTOWTDI!" -- TimToady

Feel free to get in touch if you would like a couple more.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1132802]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (12)
As of 2024-04-23 08:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found