All I want for Christmas is less boilerplate
Santa's elves were once again programming away. With the population growing and Christmas more popular than ever they had replaced their hammers and saws with shiny new computers and keyboards, and CPAN modules that could order presents from Amazon and eBay and even Etsy.
It was critical that everything run smoothly, or all the girls and boys of the world would be waking up on Christmas morning to find no presents to mark Santa's visit. So, naturally, the elves had tested their code very thoroughly, taking full advantage of all the CPAN has to offer.
t/ directory was bursting with
.t files, and every time it came to create a new test a new
.t file would be created, and the first 30 or so lines of another random
.t file would be copied over to get it started.
One day one particular elf was doing this copy-paste manoeuvre when something came to him in a flash: "Copy pasting code is bad!", he realised, "I would never copy and paste this much code around in
lib/SantasWorkshop/ so why is it ok in
t/?". And, of course, he realised that it wasn't.
The elf reached for the CPAN and pulled out Test::Kit, and created a shiny new module.
And then he simply replaced all that boilerplate in the tests with
use SantasWorkshop::Test; and he got all the testing subroutines he wanted imported in a single statement.
At this point our elf got a bit excited. He replaced ALL the boilerplate in ALL the tests!
And would you believe that with all those lines of code deleted every test still passed, and every child around the world got their presents?
When word got around to Santa he was very impressed; so much so that he wanted to give Test::Kit a go on his own projects. As he read the POD for the module he let out a jolly "ho ho ho!" when he saw a feature he thought was very nice.
Now he could assert in his tests that variables were
nice(), and if anything went really wrong he just needed to use
naughty() to add a 'not ok' to his test output.
What a jolly old time Santa will have writing tests now!