Test::Class

pdcawley on 2002-07-05T11:47:58

So, you may or may not know that I've been working on and off on PerlUnit (aka Test::Unit::TestCase), a Perl port of Kent Beck's xUnit.

Now, as these things go, PerlUnit is pretty good, it's a fairly straight port of jUnit, which is a java version of the Smalltalk original, sUnit.

The problem is that it's not really very perlish. You can run PerlUnit tests in such a way that Test::Harness can use the results, but it can be awkward.

Then, along comes Test::Class and it's lovely. Adrian Howard has done a fantastic job of taking the basic ideas behind xUnit and the simple interface of Test::More/Simple that we're used to, and producing a really useful synthesis of the two.

He doesn't try and do as much as PerlUnit, and there are a few surprises if you're used to the xUnit approach where a failing assertion (which is about the granularity of C in Test::More) bails out of the current test method. PerlUnit counts test methods, Test::Class counts (and requires you to, but makes it easy) the tests done within methods. The list continues.

And then, top cap it all, Test::Class is tiny PerlUnit is, frankly, enormous. I'm sure there are times when I'll find myself hankering for some deep feature of PerlUnit, but for now, I'm switching to Test::Class.

Oh yes, and Test::Class plays well with Test::MockObject, which is another top notch testing tool.


PerlUnit vs Test.pm/Test::More

Matts on 2002-07-10T21:15:44

I've been meaning to ask for a while now - what's the difference between PerlUnit and Test.pm/Test::More? Is it just a matter of how the tests are written, or is there something fundamentally better about PerlUnit?

Re:PerlUnit vs Test.pm/Test::More

chromatic on 2002-07-10T23:43:34

PerlUnit is a port of Kent Beck's JUnit to Perl. JUnit and the like are very much tied to a strongly-OO approach of doing things. (I believe it grew out of Smalltalk.) They set up test harnesses with classes and all sorts of things that aren't necessarily Perlish, but really fit the Java model.

Test.pm is a somewhat-old Perl module. I think Larry originally wrote it. Test::More is an expanded and enhanced version of that with more features, more tests, better diagnostics, and a really spectacular backend (Test::Builder) that means it plays very nicely with lots of other testing modules. It doesn't require an OO approach to testing, which is handy in its Perlishness.

From my perspective, it seems that PerlUnit has struggled to achieve project velocity, partly because its approach is fairly different from the standard Perl testing approach, and partly because Test::More has core status. It also has Kool-Aid.

Re:PerlUnit vs Test.pm/Test::More

lachoy on 2002-07-11T03:05:10

IME, PerlUnit requires more work and planning for a task that most people never do and have little experience in. Test::More is so simple that there's no excuse not to write tests.

BTW: nice perl.com article on Test::MockObject!