		     G N A T T E S T   E X A M P L E S

In order to generate and compile test driver, make sure that 'gnattest' and
'gnatmake' commands are in your path and AUnit is in your default project path.

To generate a test driver for a number of sources you need to use gnattest
utitity. Note that in order to process given files, gnattest has to
semantically analyze the Ada sources. Therefore, test packages can only be
generated legal Ada units. Moreover, when a unit depends semantically upon
units located outside the current directory, the source search path has to be
provided when calling gnattest through a specified project file.

Invocation
----------

Thus to generate a test driver for package declared in simple.ads, just type:
  $ gnattest -Psimple.gpr

By default all files generated by gnattest are put into subdirectories of
the object directory of project file. Harness part is put in
obj/gnattest/harness and test skeletons are put in obj/gnattest/tests.

To compile and run the test driver do the following:
  $ cd obj/gnattest/harness
  $ gnatmake -Ptest_driver.gpr
  $ test_runner

Declaration of package Simple contains one subprogram declaration declaration.
Thus one test has been generated for it, as can be seen from test driver
output.

Writing Actual Test
-------------------

Now, let's write an actual test. Test packages generated by gnattest are
grandchild packages of the tested ones. So our test is declared at
simple.test_data-tests.ads.

Bodies of test routines are placed in test package bodies and are surrounded
by cpecial comment sections. Those comment sections should not be removed or
modified in order for gnattest to be able to regenerate test packages and keep
already written tests in place.
Test routine names have a special hash tag at the end which helps solving
overloading problems and other potential name collisions. To know, which test
routine corresponds to which subprogram, test package specification has
a comment below each test routine indicating the location of tested subprogram.
So, to write a test edit the body of Test_Inc_5eaee3.adb in file
obj/gnattest/tests/simple-test_data-tests.adb replacing
  Assert (Gnattest_Generated.Default_Assert_Value,
           "Test not implemented.");
with
  Assert (Inc (1) = 2, "wrong incrementation");

After recompiling the test driver you can see a successfully passed test.
Assert is an AUnit procedure that checks if the boolean expression is true, and
stores the diagnosis message for the output, if the check fails.

Re-using once written tests
---------------------------

Gnattest never overwrites test routine bodies. You can add new subprograms
to the specification of the package, but as long as subprogram declaration
stays intact the test generated for it will still fit.

To see how it works uncomment declaration of second subprogram in simple.ads
and it's body in simple.adb, then run gnattest again, compile and run the test
driver.

As you can see, the old test still passes while there is now a new unimplemeted
test for the subprogram that has just been added.
