Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
Do you know where your variables are?
 
PerlMonks  

getting Test::More test names to print out

by princepawn (Parson)
on Dec 31, 2003 at 10:29 UTC ( [id://317906]=perlquestion: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.

princepawn has asked for the wisdom of the Perl Monks concerning the following question:

Test::More is working fine, but it is not printing out the name of the test when it runs the test, even though I have something in the name argument to the is() API call. Does anyone know why? Full code of a file named limit.t run via make test enclosed

limit.t

# Before `make install' is performed this script should be runnable wi +th # `make test'. After `make install' it should work as `perl 1.t' ######################### # change 'tests => 1' to 'tests => last_test_to_print'; use strict; use warnings; use Test::More tests => 2; use SQL::AnyDBD; ######################### # Insert your test code below, the Test::More module is use()ed here s +o read # its man page ( perldoc Test::More ) for help writing this test scrip +t. ############################ ## get DB connection info ## ############################ unless ( $ENV{DBI_DSN} and $ENV{DBI_USER} and $ENV{DBI_PASS} ) { warn "A working DBI connection is required for the remaining tests +.\n"; warn "Please enter the following parameters (or pre-set in your EN +V):\n"; } sub get_line { warn " $_[0] (or accept default '$_[1]'): \n"; chomp( my $input = <STDIN> ); return length($input) ? $input : $_[1] } my $dsn = $ENV{DBI_DSN} || get_line(DBI_DSN => 'dbi:Pg:dbname=test') +; my $user = $ENV{DBI_USER} || get_line(DBI_USER => 'metaperl'); my $pass = $ENV{DBI_PASS} || get_line(DBI_PASS => ''); ###################### ## import test data ## ###################### my $dbh = DBI->connect($dsn, $user, $pass); die "Unable to connect to DB for testing!" unless $dbh; warn $dsn; my $rows_desired = 8; my $start_row = 4; my $sb = SQL::AnyDBD->new($dbh); my $sql = $sb->LIMIT(rows_desired => $rows_desired, start_row => $star +t_row); my %expect = ( Pg => [ 'LIMIT 8 OFFSET 4', 'LIMIT 8' ] ); my $driver = $dbh->{Driver}->{Name}; my $expect; sub next_expect { $expect = shift @ { $expect{$driver} } ; } next_expect; is ( $sql , $expect, 'LIMIT with rows_desired and start_row' ) ; $start_row = ''; next_expect; $sql = $sb->LIMIT(rows_desired => $rows_desired, start_row => $start_r +ow); is ( $sql , $expect, 'LIMIT with rows_desired no start_row passed' ) ;

output

~/hacks/SQL/AnyDBD $ make test /usr/bin/perl.exe "-MExtUtils::Command::MM" "-e" "test_harness(0, 'bli +b/lib', 'blib/arch')" t/*.t t/1........ + t/1........ok 1/1 + t/1........ok t/limit....A working DBI connection is required for the remaining test +s. Please enter the following parameters (or pre-set in your ENV): DBI_DSN (or accept default 'dbi:Pg:dbname=test'): DBI_USER (or accept default 'metaperl'): DBI_PASS (or accept default ''): dbi:Pg:dbname=test at t/limit.t line 46, <STDIN> line 3. + t/limit....ok 1/2 + t/limit....ok 2/2 + t/limit....ok All tests successful. Files=2, Tests=3, 6 wallclock secs ( 0.26 cusr + 0.34 csys = 0.61 C +PU) ~/hacks/SQL/AnyDBD $


Carter's compass: I know I'm on the right track when by deleting something, I'm adding functionality

Replies are listed 'Best First'.
Re: getting Test::More test names to print out
by hanenkamp (Pilgrim) on Dec 31, 2003 at 10:49 UTC

    Running make test runs Test::Harness which runs your test scripts. You should check the documentation for Test::Harness:

    test names

    Anything after the test number but before the # is considered to be the name of the test.

    ok 42 this is the name of the test

    Currently, Test::Harness does nothing with this information.

Re: getting Test::More test names to print out
by lachoy (Parson) on Dec 31, 2003 at 12:02 UTC
    If you use Module::Build you can do:
    $ perl Build.PL $ ./Build test verbose=1

    FWIW, it's pretty simple to maintain both 'Makefile.PL' and 'Build.PL'...

    Chris
    M-x auto-bs-mode

Re: getting Test::More test names to print out
by strider corinth (Friar) on Dec 31, 2003 at 12:54 UTC
    I use Test::More all the time in modules I build. Because one of its goals is to create summarized output for people building your module on their machines, running a simple make test won't produce very helpful output. If you want the test names printed with individual results, try perl t/limit.t.

    --
    Love justice; desire mercy.
Re: getting Test::More test names to print out
by MidLifeXis (Monsignor) on Dec 31, 2003 at 15:00 UTC

    make test TEST_VERBOSE=1

    --MidLifeXis

Re: getting Test::More test names to print out
by DapperDan (Pilgrim) on Dec 31, 2003 at 17:12 UTC
    Recent versions (>= 2.32) of Test-Harness (2.40) have a wonderful new script called prove.

    It lets you run your tests in various ways without using make. It has a --verbose command-line switch.

Re: getting Test::More test names to print out
by PodMaster (Abbot) on Dec 31, 2003 at 19:54 UTC
    If you're going to be prompting the user, please use ExtUtils::MakeMaker's prompt function. It's a better idea not to prompt at all, but skip tests if certain %ENV variables aren't there, like DBI_DSN...

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

      prompt does not write to STDERR... it therefore prints nothing when used with make test.


      Carter's compass: I know I'm on the right track when by deleting something, I'm adding functionality
        The reason you should use MakeMaker's prompt function is because it detects that it is not running interactively ... $default will be used without prompting. This prevents automated processes from blocking on user input.". Prompting from tests is just not a good idea, and prompting on STDERR is not a fix (just screws up automated testing).

        MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
        I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
        ** The third rule of perl club is a statement of fact: pod is sexy.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://317906]
Front-paged by TStanley
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.