3 use Test::Harness 1.1601 ();
5 use vars qw($VERSION @ISA @EXPORT $ntest %todo);
9 @EXPORT= qw(&plan &ok &skip $ntest);
15 # Use of this variable is strongly discouraged. It is set
16 # exclusively for test coverage analyzers.
17 $ENV{REGRESSION_TEST} = $0;
20 croak "Test::plan(%args): odd number of arguments" if @_ & 1;
22 for (my $x=0; $x < @_; $x+=2) {
23 my ($k,$v) = @_[$x,$x+1];
24 if ($k =~ /^test(s)?$/) { $max = $v; }
25 elsif ($k eq 'todo' or
26 $k eq 'failok') { for (@$v) { $todo{$_}=1; }; }
27 else { carp "Test::plan(): skipping unrecognized directive '$k'" }
29 my @todo = sort { $a <=> $b } keys %todo;
31 print "1..$max todo ".join(' ', @todo).";\n";
38 my ($ok, $guess) = @_;
39 carp "(this is ok $ntest)" if defined $guess && $guess != $ntest;
40 $ok = $ok->() if (ref $ok or '') eq 'CODE';
43 print("ok $ntest # Wow!\n");
45 print("ok $ntest # (failure expected)\n");
48 print("not ok $ntest\n");
55 my ($toskip, $ok, $guess) = @_;
56 carp "(this is skip $ntest)" if defined $guess && $guess != $ntest;
57 $toskip = $toskip->() if (ref $toskip or '') eq 'CODE';
59 print "ok $ntest # skip\n";
72 Test - provides a simple framework for writing test scripts
78 BEGIN { plan tests => 5, todo => [3,4] }
83 ok(0); #ok, expected failure (see todo above)
84 ok(1); #surprise success!
86 skip($feature_is_missing, sub {...}); #do platform specific test
90 Test::Harness expects to see particular output when it executes test
91 scripts. This module tries to make conforming just a little bit
92 easier (and less error prone).
94 =head1 TEST CATEGORIES
100 These tests are expected to succeed. If they don't, something is
103 =item * SKIPPED TESTS
105 C<skip> should be used to skip tests for which a platform specific
106 feature isn't available.
110 TODO tests are designed for the purpose of maintaining an executable
111 TODO list. These tests are expected NOT to succeed (otherwise the
112 feature they test would be on the new feature list, not the TODO
115 Packages should NOT be released with successful TODO tests. As soon
116 as a TODO test starts working, it should be promoted to a normal test
117 and the new feature should be documented in the release notes.
123 L<Test::Harness> and various test coverage analysis tools.
127 Copyright © 1998 Joshua Nathaniel Pritikin. All rights reserved.
129 This package is free software and is provided "as is" without express
130 or implied warranty. It may be used, redistributed and/or modified
131 under the terms of the Perl Artistic License (see
132 http://www.perl.com/perl/misc/Artistic.html)