Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Redundancy is not something you want in your code, and tests are code.

But most of the redundancy of the tests is actually encapsulated in functions (much as you would do to deal with regular code redundancy). I fear that to try and remove the redunancy would result in my not being able to use the functions (test would get to specialized) and while it would reduce redundant tests, it would decrease the modularity of my test code. Is this still not ok?

I test every method before its called with can_ok, and I (re)test the same method on each instance I create.
I would not do this. If the methods are called once and succeed, that should be enough.

Yeah this one seemed like I was over the edge. Thanks for confirming that.

Testing with can() is not very useful, since that isn't really calling the interface to your class.

I am actually not using can, but Test::More::can_ok which no doubt it implemented in terms of can (though I have not delved into the source code to be sure, and the difference is probably neglible). I do have to disagree that can is not "really calling the interface to my class" though. Sure it can be calling a subclass potentially, but IMO thats the class interface (just inherited). I view these tests in particular (the Interface ones), as a means of helping me keep my API straight across versions/updates. It makes no assumptions about implementation, but only that the API is the same. It has already proven useful in tracking down a bug in an older installation of our framework, by finding where an API had changed between versions, but had gotten missed while someone was making changes to the code which used the framework. Why do you feel this is not "really the class interface" I am interested to know?

Unless these constants are a part of your public API, you should not be testing them at all.

They actually are part of the public API, which is why I wanted to test them.

I don't see how you could do that without embedding the values of the constants in your test, which would be wrong

Very true (and exactly what I was doing (Bad programmer! Bad!)), but being part of the public API I want to test them, I suppose that just testing that they are there (can_ok) is good enough. Do you agree?


In reply to Re: Re: Testaholics Anonymous (or how I learned to stop worrying and love Test::More) by stvn
in thread Testaholics Anonymous (or how I learned to stop worrying and love Test::More) by stvn

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?

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

    How do I use this? | Other CB clients
    Other Users?
    Others drinking their drinks and smoking their pipes about the Monastery: (1)
    As of 2021-04-18 00:51 GMT
    Find Nodes?
      Voting Booth?

      No recent polls found