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.
|
---|