Obviously, unit tests have their greatest value at the time of the development of the unit itself. Well-designed unit tests provide evidence that the unit performs its intended function, that the software design executes as intended, and allows the developer (or tester) to test the unit with inputs and states that may be difficult to produce at an integrated level.
However, once that unit is complete, running the unit test again may have very low value. Certainly it will obtain the same result when executed as a unit test. However, this seems to be at odds with the prevailing opinion that unit tests should be run daily or with every build. One might ask the question, “Why should I re-run a unit test for a software unit that has not changed?” Let’s explore this question just a bit.
Re-running a unit test provides some evidence that the software unit did not change, or at least it did not change in such a way that it affected the pass/fail criteria of the unit test. This is an important distinction as there may be some changes to units for which the unit test will not discriminate. Assuming the unit test has adequate and proper coverage, this can be an acceptable situation.
Secondly, when unit tests are automated, re-running is essentially free and it can help convince outsiders like FDA that there has been enough testing. For instance, statements like “100% unit test coverage was repeated with the final build” can be reassuring to the regulator and make it unnecessary or unlikely for them to determine the impact of some unit tests that were run on very early builds of the system. Keep in mind that the term “free” is used loosely here and does not apply to all systems.
Thirdly, you might be using a scheme where the inputs are different for each run or randomized in some fashion. Clearly regression runs of unit tests have value in this case.
Finally, you may use a log generated from a unit test for some other purpose and you need that logged data for the latest release. Rather than having to justify why the data is not from the production release or equivalent, you simply run it again.
SoftwareCPR can provide assistance ranging from validation documentation review and assessment, to hands-on risk-based V&V planning, testing, and development of unit tests automation for standalone or embedded medical device software including Mobile Medical Apps.
Alan Kusinitz provided input and review.