[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Omaha.pm] Test::More is() is cool
Cool... is() and its sibling classes save a lot of tedious writing of manual verbosity when a test fails...
Objects & test suites rock.
j
jhannah@loadbal3 ~/M/Pegasus/Message/t $ cat production_log_trailer.t
use Test::More tests => 16;
use Model::Pegasus::Message::t::production_log_trailer;
ok(my $t = Model::Pegasus::Message::t::production_log_trailer->new(
'/usr/lib/perl5/site_perl/Omni/MVC/Model/Pegasus/Message/t/production_log_trailer.t.sample'
), "new()");
is($t->get_request, "A", "get_request");
is($t->get_response, "a", "get_response");
is($t->get_time, "1.1", "get_time");
ok($t->next(), "next()");
is($t->get_request, "B", "get_request");
is($t->get_response, "b", "get_response");
is($t->get_response, "something else", "get_response");
is($t->get_time, "2.2", "get_time");
ok($t->next(), "next()");
is($t->get_request, "C", "get_request");
is($t->get_response, "c", "get_response");
is($t->get_time, "3.3", "get_time");
ok($t->next(), "next()");
is($t->get_request, "A", "get_request");
is($t->get_response, "a", "get_response");
is($t->get_time, "1.1", "get_time");
jhannah@loadbal3 ~/M/Pegasus/Message/t $ perl production_log_trailer.t
1..16
ok 1 - new()
ok 2 - get_request
ok 3 - get_response
ok 4 - get_time
ok 5 - next()
ok 6 - get_request
ok 7 - get_response
not ok 8 - get_response
# Failed test (production_log_trailer.t at line 14)
# got: 'b'
# expected: 'something else'
ok 9 - get_time
ok 10 - next()
ok 11 - get_request
ok 12 - get_response
ok 13 - get_time
ok 14 - next()
ok 15 - get_request
ok 16 - get_response
ok 17 - get_time
# Looks like you planned 16 tests but ran 1 extra.