Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
go ahead... be a heretic
 
PerlMonks  

Re: TDD of non-module code

by sundialsvc4 (Monsignor)
on Jan 24, 2012 at 14:02 UTC ( #949686=note: print w/ replies, xml ) Need Help??


in reply to TDD of non-module code

It might help promote a meaningful discussion if you would tell us a little more about your overall testing strategy.   How are you contemplating the process of “testing,” and what (if any ...) Perl test-frameworks are you using?


Comment on Re: TDD of non-module code
Re^2: TDD of non-module code
by davies (Vicar) on Jan 24, 2012 at 15:04 UTC

    This is my first attempt at TDD in Perl. I'm using Test::Simple and nothing more complicated than ok. My approach to coding is to write the test, check that it fails and then write the code to make is pass. I'm trying to write the code from the bottom up, so that the first thing I did was to create the Excel instance. Then I accessed the code modules and made sure that I was getting the sheet names and line counts back. Then, getting sick of closing orphan instances manually, I wrote the code to close the created Excel instance. Then I wrote code to open the output files. And so on.

    I'm not sure if this answers your question "how are you contemplating the process of “testing”", but what I want is a battery of tests that mean that, when I make a change, I can have some reassurance that I haven't made things worse.

    Regards,

    John Davies

      This is my first attempt at TDD in Perl. I'm using Test::Simple and nothing more complicated than ok.

      The Test-Simple distribution includes the Test::More module - since you already have it installed, you might as well use it. For an example of how this will improve your life, consider this test:

      ok(animal() eq 'monkey', 'animal() returned monkey')

      Using the is function from Test::More the same test might be written like this:

      is(animal(), 'monkey', 'check animal() return value')

      The difference is that when your test fails, the diagnostic output will tell you what value was expected and what was actually received - making things much easier to debug.

      Test::More has a number of handy functions like this which will save your time.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://949686]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (10)
As of 2014-04-21 15:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (495 votes), past polls