Irritating the coworkers

Ovid on 2003-05-15T21:39:31

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');
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',   '... 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:

isa_ok($data->{po}, 
    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().


On irritating co-workers ...

rob_au on 2003-05-15T22:57:15

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 :-)

Lining up

pudge on 2003-05-20T23:59:00

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