Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Writing tests when you don't know what the output should be

by LanX (Saint)
on May 17, 2016 at 20:22 UTC ( [id://1163259]=note: print w/replies, xml ) Need Help??


in reply to Writing tests when you don't know what the output should be

I'd split up the different phases ( like
  • reading/filtering directory,
  • reading data from file,
  • operating on data structure,
  • ...
) into different subs and unit test them against typical cases.

And after testing all small building steps you test some big one combining easier ones and so on.

Of course you have to mock data, but with this approach you only need to simulate the simpler building cases that convince you.

The trick is to add new tests as soon that you discover a bug caused by an edge case you forgot to cover.

With this incremental approach the probability of bugs shrinks very fast in linear time.

UPDATE

I think a good test suite combines the qualities of a spider web and a pyramid.

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!

  • Comment on Re: Writing tests when you don't know what the output should be

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2024-04-20 15:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found