in reply to writing tests on modules
It helps if you think of your test suite as the most detailed specification for your modules. Any functionality your module is expected to deliver should be tested. Any failure condition your module can encounter should be tested to see whether the failure is handled correctly (for example does the module die when encountering an out-of-bounds value or does it return undef and log an error). The easiest way to do this is to write your tests for a given functionality before you write the implementation. Don't write a single line of code without first writing a test for it.
For the example you give, returning a random array element, off the top of my head I can think of the following tests:
|
---|