Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Ovid (2709)

  (email not shown publicly)
AOL IM: ovidperl (Add Buddy, Send Message)

Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.

Journal of Ovid (2709)

Thursday May 15, 2003
04:39 PM

Irritating the coworkers

[ #12225 ]

I really don't mean to, but I suspect that my latest experiment might annoy the heck out of my coworkers. The test program that I am currently working on has 259 tests.

($page,$data) = $CLASS->handle($cgi);
ok( $page && $data, 'Building with a purchase order id should succeed');
is( $page, SCREEN, '... with the search template name' );
is( ref $data, 'HASH', '... and a hashref' );
ok( %$data, '... which should not be empty' );
ok(exists $data->{action}, '... and it should have an "action" key');
is($data->{action},'build', '... which describes the action');
ok(!exists $data->{vendors}, '... and there should not be a list of vendors');
ok(exists $data->{po}, '... but it should have a purchase order key');
isa_ok($data->{po}, PosX::PurchaseOrder => '... and the value');
my $desc = $data->{po}->description;
ok($desc, '... and the po should have a description');
is($desc, 'Test::Harness description',
    '... and it should be the one we set it to');

Unfortunately, many lines of test code like that can get ugly fast. So I did a curious thing.

($page,$data) = $CLASS->handle($cgi);
ok( $page && $data,          'Building with a purchase order id should succeed') ;
is( $page, SCREEN,           '... with the search template name' );
is( ref $data, 'HASH',       '... and a hashref' );
ok( %$data,                  '... which should not be empty' );
ok(exists $data->{action},   '... and it should have an "action" key');
is($data->{action},'build'   '... which describes the action');
ok(!exists $data->{vendors}, '... and there should not be a list of vendors');
ok(exists $data->{po},       '... but it should have a purchase order key');
    PosX::PurchaseOrder =>   '... and the value');
my $desc = $data->{po}->description;
ok($desc,                    '... and the po should have a description');
is($desc, 'Test::Harness',   '... and it should be the one we set it to');

I am finding that quickly scanning through the code is much easier now as the the test names stand out much more cleanly.

And on a side note, the following:

    PosX::PurchaseOrder =>   '... and the value');

Produces this:

ok 224 - ... and the value isa PosX::PurchaseOrder

That lets me get over the annoyance of not being able to assign a "readable" name to isa_ok().

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • How can a good test suite be to the irritation of your co-wrokers? If anything, I would think that it would be welcomed with open arms.

    To have some fun with my co-workers, I wrote this [] little snippet of evil code :-)

  • I've long been a fan of lining up large blocks of similar statements. It makes it much easier to read.