Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
..but even bad tests are better than no tests, right?

Wrong.

A bad API is not improved by a set of tests that nail down every aspect of its misbehaviour. Furthermore tests are code like any other, and good coding principles apply just as much.

About your main question, I agree that inheriting the tests is better, and here is the argument that I would give back to the other programmer. Suppose that your subclass is written and you copy tests. If anyone now extends the superclass, then either subclasses have untested behaviour or else the implementer has to track down every subclass and cut-and-paste the behaviour. This is exactly the kind of cut-and-paste which is likely to break that object-oriented techniques are supposed to protect you from.

However if your strategy is to inherit tests then both your present and future behaviour will get tested. True, it is possible to break your module by changing just the core module and changing its tests without notifying you. But this breakage is exactly the same risk that anyone using any module faces. No strategy can really protect you from rogue modifications, and attempting to do so by producing masses of redundant code loses productivity to what is really an education issue.


In reply to Re: Inheriting Tests and Other Test Design Issues by tilly
in thread Inheriting Tests and Other Test Design Issues by Ovid

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (7)
As of 2024-03-28 16:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found