Tuesday, March 11, 2008

TDD in Perl

Pair programming in 'Agile software development training ' was stunning experience last week. There are lots of things I learned about Extreme programming. Among them, I thought I could apply TDD in my routine.

I learned it with my pair programmer under Python environment,
my favorite language is per and I think Perl can do what Python do
even through lots of people against it.

Today, I search the CPAN library for test environment of Perl.
Among the test modules for various purposes, I think below
2 modules are enough for me to follow what I learned in the
training course.

Test::Simple
Test::More


Exam code using Test::Simple

use Test::Simple tests=>1; # indicate how many tests in the code
$expect=1;
$result=1;
ok ( $expect eq $result, 'Test1');


Exam code using Test::More


use Test::More qw(no_plan); # Possible not to determine how many tests
$expect=1;
$result=1;
ok ( $expect eq $result, 'Test1')
or is ( $expect eq $result, 'Test1');

TODO: {
ok(foo(),'Todo1");
ok(foo() ,1, "Todo2");
}

sub foo {
return 1;

}