Next: , Previous: Creating Sample Bodies Using gnatstub, Up: Top

26 Creating Unit Tests Using gnattest

gnattest is an ASIS-based utility that creates unit-test stubs as well as a test driver infrastructure (harness). gnattest creates a stub for each visible subprogram in the packages under consideration when they do not exist already.

In order to process source files from a project, gnattest has to semantically analyze the sources. Therefore, test stubs can only be generated for legal Ada units. If a unit is dependent on other units, those units should be among the source files of the project or of other projects imported by this one.

Generated stubs and harnesses are based on the AUnit testing framework. AUnit is an Ada adaptation of the xxxUnit testing frameworks, similar to JUnit for Java or CppUnit for C++. While it is advised that gnattest users read the AUnit manual, deep knowledge of AUnit is not necessary for using gnattest. For correct operation of gnattest, AUnit should be installed and aunit.gpr must be on the project path. This happens automatically when Aunit is installed at its default location.