in reply to Best Way to Make a Custom Testing Module
So often you open up a test suite and see 20 test programs starting with something like this:Is the difficulty just that it makes for boring reading, or are you annoyed at the amount of typing? The way I deal with this sort of thing these days is to use code generation templates. Myself I work with emacs, and the template.el package (along with a package I wrote myself, perlnow.el). I keep meaning to look into ways of doing this with, say, Template::Toolkit, (that would be more likely to be more widely popular with perl programmers).
use Test::More tests => 23;
use Test::Differences;
use Test::Exception;
The advantage of using a template to generate such stuff is that it places a little more of the burden on the code author (rather than creating One More Custom Module that someone reading the code needs to understand). I also like the way it makes it a little easier to start with a standard way of doing things, and then diverge from it if there's a reason to: you can just mutate the code the template inserted at will, without fear of effecting anything else that uses the template. And when you find a trick that you want to use everywhere, the changes to the templates only effect new code, you don't need to re-test all the existing code to look for accidental breakage.
|
|---|