Pathologically Eclectic Rubbish Lister | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
markmoon,
Everyone here has given some great advice, but for me the testing lightbulb went off when I first really saw and messed around with an existsing test script. It was always too easy for me to put off reading tutorials and such (yes, the wrong kind of laziness), but when i finally got in front of a test that was already set up and ready to go, it all clicked. So in the spirit of passing on what worked for me, I have mocked up a quick test script that might help you get your feet wet. First things first, you need to download and install the latest versions of Test::Simple (which has Test::More in it, which is your workhorse), and Test::Harness. You more than likely already have both on your system, but it can't hurt to get them up to date, and plus, Test::Harness comes with this great utility script called "prove", which makes running tests a lot simpler. Now, here goes the code, it is purposely VERY simple so as not to cloud the issue, which is testing, with funky code. Put this code into a file called "Module.pm"
Put this code into a file called "test.t"
Now make sure both files (MyModule.pm and test.t) are in the same directory, and then run this from the command line (assuming you have already cd/chdir to the same directory). You should see the following output: And thats all. Obviously a more complex module would require a more complex tests, and take note, my tests are very simplistic. But this might give you help in getting started, as it helped me. -stvn In reply to Re: Testing for Beginners
by stvn
|
|