Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^3: Testing at the right granularity

by revdiablo (Prior)
on Apr 19, 2005 at 18:15 UTC ( #449369=note: print w/replies, xml ) Need Help??


in reply to Re^2: Testing at the right granularity
in thread Testing at the right granularity

Nonetheless, I sometimes feel that maybe a more compact test (like the first) would do equally good as the bloated one.

As long as they're testing the same things, yes. In my opinion, your 2nd snippet of code is by far inferior to the 1st. It is more verbose, and less clear. Keep in mind that writing tests still means following good coding practices. In this case, the simplest and most obvious solution is usually the best.

If they were testing different things, though, then it's not so clear. I would lean towards testing as much as possible, as ambs said. Note that I am talking about this in terms of semantic tests, not in terms of number of "physical" test cases you can squeeze out. Update: dragonchild seems to also touch on this same idea in Re^3: Testing at the right granularity.

If you're concerned about putting a lot of unrelated tests together, and thinking they may get drowned out in the noise, consider putting them in separate test files. This allows you to have your cake and eat it too. You get logical groupings, but also high granularity.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2020-11-30 01:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?