Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67a
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Libraries

    Test::Simple 0.80

    Download button

    No screenshots available
    Downloads: 352  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    Good (3.6/5)
    8 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Michael G Schwern | More programs
    Perl Artistic License / FREE
    April 8th, 2008, 13:50 GMT
    ROOT / Programming / Libraries

     Read user reviews (0)  Refer to a friend  Subscribe

    Test::Simple description

    Test::Simple is a Perl module with basic utilities for writing tests.

    Test::Simple is a Perl module with basic utilities for writing tests.

    SYNOPSIS

    use Test::Simple tests => 1;

    ok( $foo eq $bar, 'foo is bar' );

    ** If you are unfamiliar with testing read Test::Tutorial first! **

    This is an extremely simple, extremely basic module for writing tests suitable for CPAN modules and other pursuits. If you wish to do more complicated testing, use the Test::More module (a drop-in replacement for this one).
    The basic unit of Perl testing is the ok. For each thing you want to test your program will print out an "ok" or "not ok" to indicate pass or fail. You do this with the ok() function (see below).

    The only other constraint is you must pre-declare how many tests you plan to run. This is in case something goes horribly wrong during the test and your test program aborts, or skips a test or whatever. You do this like so:

    use Test::Simple tests => 23;

    You must have a plan.

    ok
    ok( $foo eq $bar, $name );
    ok( $foo eq $bar );

    ok() is given an expression (in this case $foo eq $bar). If it's true, the test passed. If it's false, it didn't. That's about it.

    ok() prints out either "ok" or "not ok" along with a test number (it keeps track of that for you).

    # This produces "ok 1 - Hell not yet frozen over" (or not ok)
    ok( get_temperature($hell) > 0, 'Hell not yet frozen over' );

    If you provide a $name, that will be printed along with the "ok/not ok" to make it easier to find your test when if fails (just search for the name). It also makes it easier for the next guy to understand what your test is for. It's highly recommended you use test names.

    All tests are run in scalar context. So this:

    ok( @stuff, 'I have some stuff' );
    will do what you mean (fail if stuff is empty)

    Test::Simple will start by printing number of tests run in the form "1..M" (so "1..5" means you're going to run 5 tests). This strange format lets Test::Harness know how many tests you plan on running in case something goes horribly wrong.
    If all your tests passed, Test::Simple will exit with zero (which is normal). If anything failed it will exit with how many failed. If you run less (or more) tests than you planned, the missing (or extras) will be considered failures. If no tests were ever run Test::Simple will throw a warning and exit with 255. If the test died, even after having successfully completed all its tests, it will still be considered a failure and will exit with 255.

    So the exit codes are...
    0 all tests successful
    255 test died or all passed but wrong # of tests run
    any other number how many failed (including missing or extras)

    If you fail more than 254 tests, it will be reported as 254.

    This module is by no means trying to be a complete testing system. It's just to get you started. Once you're off the ground its recommended you look at Test::More.

    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    write tests | module testing | Perl module | Test::Simple | write | tests

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM