Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Ahh - this really sounds like you are making this harder than it should be. I like to have the following kind of structure (below). In the XP fashion I like to write my tests first as I build up the object. I must admit to not using h2xs that much, but we have a template that is used to create new modules which need to inherit from a base class anyways so I guess we're still being structured (whew).
project/lib/Foo/Bar/ project/lib/ project/t/test1.t $ cat t/test1.t use lib './lib'; use strict; my $error; BEGIN { use vars qw($TESTCOUNT); use Test; # so we actually do some more stuff # here to load the Test module # since we distribute it with our package # in case the user doesn't have it $TESTCOUNT = 3; plan tests => $TESTCOUNT; # do some other testing eval { Some::module::Needed; }; if( $@ ) { $error =1 } } END { # if we exit prematurely in the test the testcount # will still be okay (assuming we want to bail # when some module isn't installed or # or the network is unavailable, etc. foreach ( $Test::ntest..$TESTCOUN) { skip("unable to run all the tests",1); } } if( $error ) { exit(0) } use Foo; use Foo::Bar::Baz; my $foo = new Foo(-id => '10'); ok($foo); ok($foo->id, '10); my $baz = new Foo::Bar::Baz(-magicword => 'peanutbuttersandwiches'); ok($base->magic, 'peanutbuttersandwiches'); $ perl -I. -w t/test1.t 1..3 ok 1 ok 2 ok 3
The above wasn't actually run but hopefully I didn't leave any typos in - if you don't want to put things in a lib directory you can always s/lib/ above and all will work (your would be doing use lib '.' instead). You can also have PERL5LIB set to include XXX/project/lib. I may be overzealous using the perl -I. -w for my tests when I have PERL5LIB set, but since often I have version of the toolkit installed while I'm working on the next one, I don't want to get confused about which code I am actually running.

In reply to Re: Re: Re: MakeMaker, h2xs, and writing CPAN modules by stajich
in thread MakeMaker, h2xs, and writing CPAN modules by perrin

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 perusing the Monastery: (2)
    As of 2020-02-23 08:41 GMT
    Find Nodes?
      Voting Booth?
      What numbers are you going to focus on primarily in 2020?

      Results (102 votes). Check out past polls.