Here is the docs for Test::Simple, an extremely basic, extremely easy
to learn testing module for those just learning to write tests.  It
addresses the issue of getting people to write tests *at all*.  Forget
about todos and skips and halting problems.  Those will be addressed
in a different module (the Testing module we've been talking about will
probably become Test::More).

I was tempted to throw in a function to test that a module loaded (to
replace the "magic" that h2xs throws into its test) but if a module
fails to load, the test will blow up anyway so its a moot point at
this level.  I might throw one onto Test::More.


NAME
    Test::Simple - Basic utilities for writing tests.

SYNOPSIS
      use Test::Simple;

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

DESCRIPTION
    This is an extremely simple, extremely basic module for writing tests
    suitable for CPAN modules and other pursuits.

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

        ok() is given an expression (in this case "$foo eq $bar"). If its
        true, the test passed. If its 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.

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

    After you test script is finished, Test::Simple will print out the
    number of tests run in the form "1..M" (so "1..5" means you ran 5
    tests). This strange format lets Test::Harness know how many tests were
    run.

    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 no
    tests were ever run Test::Simple will throw a warning and exit with -1.

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

EXAMPLE
    Here's an example of a simple .t file for the fictional Film module.

        use Test::Simple;

        use Film;  # What you're testing.

        my $btaste = Film->new({ Title    => 'Bad Taste',
                                 Director => 'Peter Jackson',
                                 Rating   => 'R',
                                 NumExplodingSheep => 1
                               });
        ok( defined($btaste) and ref $btaste eq 'Film',     'new() works' );

        ok( $btaste->Title      eq 'Bad Taste',     'Title() get'    );
        ok( $btsate->Director   eq 'Peter Jackson', 'Director() get' );
        ok( $btaste->Rating     eq 'R',             'Rating() get'   );
        ok( $btaste->NumExplodingSheep == 1,        'NumExplodingSheep() get' );

    It will produce output like this:

        ok 1 - new() works
        ok 2 - Title() get
        ok 3 - Director() get
        not ok 4 - Rating() get
        ok 5 - NumExplodingSheep() get
        1..5

    Indicating the Film::Rating() method is broken.

CAVEATS
    If your test will be run via MakeMaker, this module relies on a feature
    in Test::Harness 1.20 and up. If you don't know what MakeMaker is, don't
    worry about it.

HISTORY
    This module was conceived while talking with Tony Bowden in his kitchen
    one night about the problems I was having writing some really
    complicated feature into the new Testing module. He observed that the
    main problem is not dealing with these edge cases but that people hate
    to write tests at all. What was needed was a dead simple module that
    took all the hard work out of testing and was really, really easy to
    learn. This is it.

AUTHOR
    Idea by Tony Bowden, code by Michael G Schwern <[EMAIL PROTECTED]>,
    wardrobe by Calvin Klein.

SEE ALSO
    the Test::More manpage
        More testing functions! Once you outgrow Test::Simple, look at
        Test::More.

    the Test manpage
        The original Perl testing module.

    the Test::Unit manpage
        Elaborate unit testing.

    the Pod::Tests manpage, the SelfTest manpage
        Embed tests in your code!

    the Test::Harness manpage
        Interprets the output of your test program.




-- 

Michael G. Schwern   <[EMAIL PROTECTED]>    http://www.pobox.com/~schwern/
Perl6 Quality Assurance     <[EMAIL PROTECTED]>       Kwalitee Is Job One
The key, my friend, is hash browns.
        http://www.goats.com/archive/980402.html

Reply via email to