Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

RFC: Basic Testing Tutorial

by hippo (Chancellor)
on Jul 05, 2019 at 08:24 UTC ( #11102443=perlmeditation: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    1..1
    ok 1 The expected file "foo" is present
    
  2. or download this
    use strict;
    use warnings;
    ...
    print "1..1\n";
    print localtime(time)->year > 1999 ? 'ok' : 'not ok';
    print " 1 Not in a previous century\n";
    
  3. or download this
    1..1
    ok 1 Not in a previous century
    
  4. or download this
    use strict;
    use warnings;
    ...
    use Test::Simple tests => 1;
    
    ok localtime(time)->year > 1999, 'Not in a previous century';
    
  5. or download this
    use strict;
    use warnings;
    ...
    use Test::More tests => 1;
    
    cmp_ok localtime(time)->_year, '>', 1999, 'Not in a previous century';
    
  6. or download this
    1..1
    not ok 1 - Not in a previous century
    ...
    #         >
    #     '1999'
    # Looks like you failed 1 test of 1.
    
  7. or download this
    use strict;
    use warnings;
    ...
    cmp_ok $now->_year, '>', 1999, 'Not in a previous century';
    is $now->time, $now->hms, 'The time() and hms() methods give the same 
    +result';
    like $now->fullday, qr/day$/, 'The dayname ends in "day"';
    
  8. or download this
    use strict;
    use warnings;
    ...
        skip 'Non-English locale', 1 unless substr ($ENV{LANG} // 'en', 0,
    + 2) eq 'en';
        like $now->fullday, qr/day$/, 'The dayname ends in "day"';
    }
    
  9. or download this
    plan tests => scalar @array;
    
  10. or download this
    done_testing ();
    exit;
    
  11. or download this
    $ prove /tmp/bar.t
    /tmp/bar.t .. 1/3 
    ...
      Non-zero exit status: 1
    Files=1, Tests=3,  0 wallclock secs ( 0.03 usr  0.00 sys +  0.06 cusr 
    + 0.01 csys =  0.10 CPU)
    Result: FAIL
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://11102443]
Front-paged by Discipulus
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2020-02-24 02:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What numbers are you going to focus on primarily in 2020?










    Results (104 votes). Check out past polls.

    Notices?