|
Perl Testing
A D V E R T I S E M E N T
Perl Programming
Perl Programming Styles
- Here's some of the many ways people write their tests:
- t/op/sysio.t
print 'not ' unless (syswrite(O, $a, 2) == 2);
print "ok 20\n";
- ext/Cwd/t/cwd.t
print +($getcwd eq $start ? "" : "not "), "ok 4\n";
- t/pod/plainer.t
unless( $returned eq $expected ) {
print map { s/^/\#/mg; $_; }
map {+$_} # to avoid readonly values
"EXPECTED:\n", $expected, "GOT:\n", $returned;
print "not ";
}
printf "ok %d\n", ++$test;
Maintenance nightmare.
I'm ok, you're ok
#!/usr/bin/perl -w
use Test::Simple tests => 1;
ok( 1 + 1 == 2 );
- "ok" is the backbone of Perl testing.
- If the expression is true, the test pass.
- False, it fails.
- Every conceivable test can be performed just using ok().
Looking for Software Testing eBooks and Interview Questions? Join now and get it FREE!
|
Recommended Resources
• Testing Interview Questions -
http://www.coolinterview.com/type.asp
• Testing Tools Interview Questions -
http://www.coolinterview.com/type.asp
• What is Software Testing?-
http://en.wikipedia.org/wiki/Software_testing
• Software QA & Testing Resource Center-
http://www.softwareqatest.com/
• Testing Faqs-
http://www.testingfaqs.org/ |
|