4.3 Unit Test Framework
In keeping with good software practice, FLASH4 incorporates a unit
test framework that allows for rigorous testing and easy isolation of
errors. The components of the unit test show up in two different
places in the FLASH source tree. One is a dedicated path in the
Simulation unit,
Simulation/SimulationMain/unitTest/UnitTestName, where
UnitTestName is the name of a specific unit test. The other place is a
subdirectory called unitTest, somewhere in the hierarchy of the
corresponding unit which implements a function Unit_unitTest
and any helper functions it may need. The primary reason for organizing unit
tests in this somewhat confusing way is that unit tests are special cases of
simulation setups that also need extensive access to internal data of the unit
being tested. By splitting the unit
test into two places, it is possible to meet both requirements without
violating unit encapsulation. We illustrate the functioning of the
unit test framework with the unit test of the Eos unit. For more
details please see Sec:Eos Unit Test. The Eos unit test needs its
own version of the routine Driver_evolveFlash which makes a
call to its Eos_unitTest routine. The initial conditions
specification and unit test specific Driver_evolveFlash are
placed in Simulation/SimulationMain/unitTest/Eos, since
the Simulation unit allows any substitute FLASH function to be placed in
the specific simulation directory. The function Eos_unitTest
resides in physics/Eos/unitTest, and therefore has access to all
internal Eos data structures and helper functions.