Next: , Previous: Testing with Contracts, Up: Creating Unit Tests Using gnattest


26.12 Additional Tests

gnattest can add user-written tests to the main suite of the test driver. gnattest traverses the given packages and searches for test routines. All procedures with a single in out parameter of a type which is derived from AUnit.Test_Fixtures.Test_Fixture and that are declared in package specifications are added to the suites and are then executed by the test driver. (Set_Up and Tear_Down are filtered out.)

An example illustrates two ways of creating test harnesses for user-written tests. Directory additional_tests contains an AUnit-based test driver written by hand.

     <install_prefix>/share/examples/gnattest/additional_tests/

To create a test driver for already-written tests, use the –harness-only option:

     gnattest -Padditional/harness/harness.gpr --harness-dir=harness_only \
       --harness-only
     gnatmake -Pharness_only/test_driver.gpr
     harness_only/test_runner

Additional tests can also be executed together with generated tests:

     gnattest -Psimple.gpr --additional-tests=additional/harness/harness.gpr \
       --harness-dir=mixing
     gnatmake -Pmixing/test_driver.gpr
     mixing/test_runner