Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: Philosophical question about testing

by Old_Gray_Bear (Bishop)
on Oct 28, 2010 at 00:04 UTC ( #867873=note: print w/ replies, xml ) Need Help??

in reply to Philosophical question about testing

You said: "Does this make me a bad person?"

Not necessarily bad, just cautious -- it doesn't feel right -- and pragmatic, you went and asked for a second opinion.

When I am writing tests I try as much as possible to get into the 'assertion' mind-set -- is the value returned from my method equal to 'X'? Simple, yes/no tests.

If my method has side-effects (I call it with Y, I get X back, and by the way, the file is now readable....), I'd think about alternative ways of testing my side-effect. Say, create a file without read-permission, call my routine that sorts out the permissions bits to what I want. Then open the file for reading and check the return value from open() ('true' on success, and 'false' on failure). This way you could write a binary test for a successful open. Any function that you can use the  or die ... idiom on is susceptible to this approach.

If you haven't run across Ian Langworth and cromatic's book Perl Testing: A Developer's Notebook, you should. They have a number of recipes for testing most everything under the Sun using Perl and the Test Anything Protocol.

I Go Back to Sleep, Now.


Comment on Re: Philosophical question about testing
Select or Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (4)
As of 2016-05-26 01:44 GMT
Find Nodes?
    Voting Booth?