Next: Design By Contract /
Up: Unit Testing / Levelized
Previous: Preliminary Levelized Design for
- Every component contains its own specific driver routine
for unit testing.
- All CÆSAR files are filtered through the gm4 macro
preprocessor.
- Unless the UNITTEST flag is set, the
Unit Test driver routine is filtered out.
Example:
module Template_Class
! Module data and routines.
end module Template_Class
ifdef([UNITTEST],[
program Unittest
! Testing code.
end
])
- Each component to be unit tested must be compiled and linked
with a unique subset of CÆSAR.
- The make utility is not well suited to this task.
- CÆSAR uses Document to extract and run a unit test script
imbedded in each component.
Example:
! To test this module,
!
! Begin_Self_Test
! % echo "Preprocessing unit test on Template..."
! % m4 -P -I../include ../constants/numbers.F90 > unittest.f90
! % m4 -P -I../include ../constants/flags.F90 » unittest.f90
! % m4 -P -I../include ../debug/verify.F90 » unittest.f90
! % m4 -P -I../include logical.F90 » unittest.f90
! % m4 -P -DUNITTEST -I../include template.F90 » unittest.f90
! % echo "Compiling unit test on Template..."
! % f90 unittest.f90 -w -o unittest
! % echo "Running unit test on Template..."
! % unittest > battery/template.test.new 2>&1
! % rm -f unittest*
! % echo "Diffing Template results with saved version..."
! % diffnewold battery/template.test.new battery/template.test
! End_Self_Test
Next: Design By Contract /
Up: Unit Testing / Levelized
Previous: Preliminary Levelized Design for
Michael L. Hall