I've read much here and there about tests, but due to my typical programming tasks I've never really needed to write any, with some minor exceptions. Now I have some codebase that has served me right for quite a lot of time, but I {want,need} to
- add features,
- next to completely rewrite it.
The point is that I want to start from the current implementation of the thingie, which in turn must be a sort of reference one, as a starting point: thus I want to write tests for any improved one, that will make sure it will behave like the former in "all" commonly covered cases. I see two possible strategies:
- generate the tests with the reference implementation, then discard it completely,
- run code from the reference implementation as a term of comparison for the tests.
The first approach is obvious, and with the second I mean something like moving code to a "private" (e.g. with a particular naming scheme) module and write tests like:
ok( func eq _Reference::func, 'func');
I see pros and cons in both ways. Any idea?!?
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.