November 2013 Archives

Why Are Fast Tests Important?

I recently made the following comment on Twitter:

EVERY tech company I've worked with has had a test suite broken in some fundamental way, even if all test pass. No exceptions.

Unfortunately, Twitter is not a great medium for exchanging ideas like this, but when challenged on this by one person, I mentioned:

Code + path coverage? Test suite runtime. Duplicate code. Procedural tests for OO code? Cut-n-paste? Skipped tests? Organization?

There's a huge amount to cover there, but I want to touch on test suite runtime for just a moment.

SOC Agile Development

Update: It's been modified slightly. Read the official announcement and the follow-up instead of this post.

As some of you know, one of my most popular talks is "Agile Companies Go P.O.P.". What you probably don't know is that this talk is actually an introduction to a full day training course I give on this topic. So far it's been a lot of fun and I cover everything from the space shuttle (which you've seen from the slides), to the Feudal era (which you haven't). However, there is one topic I don't cover enough and I think it's time to point it out: agile sucks, but it sucks less than the alternatives.

Test::Class::MOP now has an 'is testcase' trait

When I previously blogged about Test::Class::MOP, I showed the bare basics of a test. Per a suggestion from Toby Inkster, I've now added an is testcase trait for methods. Unlike Test::Class::Moose, test methods no longer need to start with test_. Instead, you can do something like this:

method simple_test($report) is testcase {
    $report->plan(1);
    is $self->test_fixture->full_name, 'Bob Dobbs',
        'Our full name should be correct';
}

Obviously there's a lot going on there, so I'll explain a bit more about this.

Porting Test::Class to the p5-mop

Stevan Little has been asking people to port things to the p5-mop-redux or to create new modules. I decided to reimplement Test::Class::Moose as Test::Class::MOP. The following works:

use mop;

class TestsFor::DateTime extends Test::Class::MOP {
   use DateTime;
   use Test::Most;

   # methods that begin with test_ are test methods.
   method test_constructor($report) {
       $report->plan(3);    # strictly optional

       can_ok 'DateTime', 'new';
       my %args = (
           year  => 1967,
           month => 6,
           day   => 20,
       );
       isa_ok my $date = DateTime->new(%args), 'DateTime';
       is $date->year, $args{year}, '... and the year should be correct';
   }
}
Test::Class::MOP->new->runtests;

While a number of tests fail, you can check it out here on github. The failing tests seem to largely be due to a few places in my tests where I relied on the old Class::MOP. The actual test code appears to work fine.

What follows are my notes (from memory) on the experience.

A Tiny Code Quiz

I'll be speaking at the 2014 German Perl Workshop, so I hope to see some of you there.

Ben Tilly posted the following on Facebook a few days ago (I've modified it every so slightly to make the possible answers clearer):

@ar1 = qw(foo bar);
@ar2 = qw(a b c d);
print scalar (@ar1, @ar2);

He argued that even experienced developers will often get this wrong. Looking at the above, we could possibly argue for any of the following to be printed:

  • 1
  • 2
  • 3
  • 4
  • 6
  • d
  • foo

Try and guess the answer without consulting the docs or reading any of the responses! I'll give a rationale for each of those after the cut (and for the record, I got the answer wrong the first time), but I won't be giving the answer -- I assume that will show up pretty quickly in the comments. Note that, of course, the following rationales are wrong (badly so in some cases), but this gives you an idea of how difficult context can be in Perl.

Seeking a new contract

I've been loving my current contract but, sadly, it's coming to an end soon. If you'd be interested in hiring me, drop me a line at info@allaroundtheworld.fr. Obviously I can probably crib together a few lines of Perl for you, but if you specifically need someone to come in and beat your test suite into submission (or create it from thin air), I'm your man.

You might find it ironic that my wife and I do international recruiting and I'm posting here, but we focus on international relocation and I'm not planning on moving. Hence, me being here :)

I've got a couple of leads already, but nothing set in stone.

About Ovid

user-pic Freelance Perl/Testing/Agile consultant and trainer. See http://www.allaroundtheworld.fr/ for our services. If you have a problem with Perl, we will solve it for you. And don't forget to buy my book! http://www.amazon.com/Beginning-Perl-Curtis-Poe/dp/1118013840/