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

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

We had a strange debate at work today. Basically, the question was whether or not it was appropriate to inherit tests. I argued that it was. If I write a subclass, I don't want to rewrite all of the tests. I just want to test what's in the subclass and possibly inherit the tests from the superclass.

The counter-argument, provided by another programmer, is that by failing to explicitly test superclass behavior in the subclass tests, we're losing information. For example, let's say I have a superclass that, amongst other things, formats numbers to have a comma every three digits. My subclasses might change some behavior, but in this example, never change the number format behavior and thus have no tests for it. The problem arises when the super class number formatter is changed to have the comma every four digits, but the subclasses don't have tests for this and thus we're altering subclass behavior without testing it.

Personally, if I have to change a super class, I don't want to find everything that might subclass from it and update all of the tests. I want to run the tests and just fix the ones that break. Copying superclass tests over and over to subclass tests strikes me as a bad idea, but I have to admit that the counter-argument was interesting.

Have you ever used Test::Class or something similar to subclass tests? Do you think it's a good or bad idea? I'm also curious about whether or not you think that good software design considerations are different for tests. Frankly, I see a lot of test code that appears poorly written (cut and paste, mostly), but even bad tests are better than no tests, right?

Cheers,
Ovid

New address of my CGI Course.


In reply to 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":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others surveying the Monastery: (5)
    As of 2020-03-31 03:13 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      To "Disagree to disagree" means to:









      Results (179 votes). Check out past polls.

      Notices?