Once again, I am creating a zoo of OO Perl modules from scratch, and given the opportunity I am using test Driven Development (TDD), which I have to say is a great way to code.
Having built three OO modules so far, I am running into a problem. I want to test creating objects with as many different combinations as possible, and my general test plan is
- Within one scope,
- Create an object by name, with a set of options
- Run some standard tests on this object
- Within another scope,
- Load the previously created object by name
- Run some standard tests on this object, including checking that all of the options are correct
- Delete the object
Ideally this leaves things exactly the way they started, which means I can run the tests over and over, without stopping to clean up afterwards.
I'd like to try lots of different choices when I create the objects, and later test that all of the choics I made were correctly stored in the instantied object. The two methods I can think of for doing that are 1. nested loops, and 2. a single loop that increments a number, along with a series of tests inside the loop that checks for a particular bit and, if set, enables that particular option.
Aside: Hmm, maybe the way I should be doing it is create a named object in one scope, and then immediately test the named object in another scope, all inside one loop ..
Neither of these seem very elegant .. I did find Math::Combinatorics on CPAN but that's not really want I'm looking for. Has anyone else come across this particular challenge?
Alex / talexb / Toronto
"Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds
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, details, 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, summary, 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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.