Tuesday, April 3, 2007

tests in Perl are easy and funny

and it used to be my nightmare. Many times I see my self scared of things that are actually easy. Probably problem in my head. I used to think that anything new is way above my limits. With this in mind actual learning takes a lot longer and in the end I many times scratch my head that it wasn't that hard. So let's change this attitude and move on to Perl tests.

I've touched Perl first time in my current job where something more powerful than bash scripting was needed to automate all we do. Firstly we had some easy perl scripts doing one task, spread around the boxes. Soon we've realized this is not going to be maintainable. Took some time and learned how to write Perl modules. There are many great articles on the web that tells you how, this one is sounds like nice summary to me.
Today I've decided and went one step further and write tests (I know they should be written in first place, but hey at least I'm writing documentation first).

So I went to perldoc Test::More and after some reading this line has stopped me:
"STOP! If you’re just getting started writing tests, have a look at Test::Simple first."
Ok, move on to perldoc Test::Simple :

"** If you are unfamiliar with testing read Test::Tutorial first! **"

And finally this seems like the one to start. First sentence there is:

" AHHHHHHH!!!! NOT TESTING! Anything but testing!
Beat me, whip me, send me to Detroit, but don’t make me write tests!
*sob*
Besides, I don’t know how to write the damned things.".

I feel like home now, anyway don't let that scare you, writing tests in Perl is actually easy in the end.

No comments: