Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I'm looking to convert DBM::Deep's test suite to use Test::Class because I need to reuse a large number of test cases. I really don't want to use a library of functions because that's going to get unwieldy very very quickly. So, I was hoping Test::Class would be the solution.

The problem is that I have classes that have waaaay more functionality than can be tested in one file. So, the recommended organisation of Foo::Bar::Test testing Foo::Bar isn't going to work.

What I'm thinking of is writing test classes that encapsulate tests given a certain setup. So, something like:

package Test::Floober; # This inherits from Test::Class use base 'My::Test::BaseClass'; sub test1 : Test(5) { my $self = shift; # Do stuff here with $self->{foo} and $self->{bar} # that were passed in at new() }
Then, in my test file, I could have something like:
use Test::Floober; my $test = Test::Floober->new( foo => 2, bar => 5 ); my $test2 = Test::Floober->new( foo => 'abcd', bar => [ 2 .. 5 ] ); Test::Class->runtests( $test, $test2 );
I got a couple questions:
  • How does the plan get set in these instances? I can run planless, but I'd prefer not to.
  • I'm not sure it will make sense in every instance to pre-build all the test cases as in the situation above. How would Test::Class know the plan then?
  • Is this a sane use of Test::Class? My only exposure to xUnit has been Rails and the tests I wrote there were variations of the stock test, not anything complex.

My criteria for good software:
  1. Does it work?
  2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?

In reply to Test::Class and test organization by dragonchild

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 contemplating the Monastery: (4)
    As of 2019-11-16 01:24 GMT
    Find Nodes?
      Voting Booth?
      Strict and warnings: which comes first?

      Results (85 votes). Check out past polls.