Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://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/Baz.pm project/lib/Foo.pm 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

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 goofing around in the Monastery: (3)
As of 2024-04-19 02:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found