Stories
Slash Boxes
Comments
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)

Ovid
  (email not shown publicly)
http://publius-ovidius.livejournal.com/
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)

Friday March 13, 2009
03:22 AM

How To Use Test::Class

[ #38636 ]

My article on Test::Class has been published on modernperlbooks.com. It's broken down into bite-sized chunks as:

  1. Organizing Test Suites with Test::Class
  2. Reusing Test Code with Test::Class
  3. Making Your Testing Life Easier (refactoring and other tricks)

For German speakers, it's also due to be published in May (I think) in $foo Perl Magazin.

One note about the article: I first wrote that a few years ago and never got around to submitting it. Clearly, since the article uses Moose and Test::Most, I've updated it quite heavily. One update I forgot is that the Test:: namespace prefix should be clarified. It should be something like Tests:, My::Test: or Test::${company_name}:: or basically anything which avoids conflicts with the Test:: namespace.

So far comments have been nice and Piers Cawley mentions it in his blog and also seems quite happy with it (that's an awesome blog post, by the way. It's an attempt to bring Devel::Declare magic to Test::Class).

One thing which didn't survive chromatic's editing was my "Tip Summary" at the end of the three parts:

  • Name your test classes consistently after the classes they're testing.
  • When possible, do the same for your test methods.
  • Don't use a constructor test named new.
  • Create your own Test::Class base class.
  • Abstract the the name of the class you're testing into a class method in your base class (possibly the most important tip).
  • Name test control methods after their attribute.
  • Decide case-by-case whether to call a control method's parent method.
  • Don't put tests in your test control methods.

Some of those might sounds odd, but if you read the articles, I explain what's going on.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Your articles helped me sort out TDD w/Moose, an issue I had worked on a couple of weeks ago. Very timely, and effective.
  • Cleared up a bit for me.

  • I've been away from Perl for a while, so this is a great resource for me to get back into testing using Test::Class and not falling back to my old .t ways. :-)

  • And reading comments under Pierses blog I found Test::Able - which boastes to be Moose based Test::Class.
    • Yeah, I was looking at that (saw in the same blog entry). Looks very cool and, because it uses a MOP, promises to make easy some things which are hard in Test::Class.