Jack Whitham, of Rapita Systems has written a nice piece on the thorough testing of software (including seemingly ‘simple’ software – one liners and such) entitled It’s hard to test software: even simple software!. His company, Rapita Systems, recently released a modified version of Tetris as a “tool demo” for their Code Coverage tool, RapiCover. As Jack states, although Tetris can be/has been implemented in as little code as a single line of BBC Basic, it is, after all, based on an NP-Hard Problem.
Like most software, a good portion of the code will be exercised after having run the application sufficiently. However, like all software, there always exists those edge cases in which the planets must align for a certain subroutine/method to be executed/invoked, It’s these rarely executed pieces of code that suffer from poor test coverage and to which coverage analysis tools lend themselves the most. His piece is a good read to get a feel for how to code and test so that more of your code is exercised and that your QA correctly tests all of the code, instead of just the 70-80% that gets executed the majority of the time.