Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: how to begin with testing?

by gwadej (Chaplain)
on Mar 23, 2009 at 13:33 UTC ( [id://752586]=note: print w/replies, xml ) Need Help??


in reply to how to begin with testing?

There's been a lot of great advice here, but I thought I would chime in with a different reference. I found the book Working Effectively with Legacy Code by Michael Feathers to be quite good for this particular issue.

One thing that Feathers covers that most other testing books don't is that the normal unit testing approach does not usually work well with legacy code (which he defines as code with no tests). He suggested a tactic he calls characterization tests. Instead of trying to verify correct behavior as you would with unit tests, characterization tests focus on current behavior.

Before making changes to legacy code (bug fixes, feature additions, refactorings, etc.), you would start by characterizing the current code, in the area of interest, with tests. Then, you can modify the tests and code in something approximating normal unit testing.

One of the most important points in the book is the explanation of the different tactics that you need to use for legacy code and new code that can be properly unit tested.

G. Wade

Replies are listed 'Best First'.
Re^2: how to begin with testing?
by jhourcle (Prior) on Mar 23, 2009 at 14:33 UTC

    I'm not familiar with that specific book, but when you mentioned 'Legacy Code', I was reminded of Peter J. Scott's book Perl Medic: Transforming Legacy Code. It also deal with being handed existing code, and having to maintain it. The third chapter covers tests -- it's not as complete as chromatic's book, but it does give an overview of the perl modules in CPAN (at the time) to handle testing.

      All three books complement each other. If you can read all three, I recommend it.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-04-19 02:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found