ACATS 3.1 User's Guide
Title Page
Contents   Index   References   Previous   Next 

4.6 Test Structure

Executable tests (class A, C, D, and E) generally use the following format: 
with Report;
procedure Testname is
   <declarations>
begin
   Report.Test ("Testname", "Description ...");
   ...
   <test situation yielding result>
   if Post_Condition /= Correct_Value then
      Report.Failed ("Reason");
   end if;
   ...
   Report.Result;
end Testname;
The initial call to Report.Test prints the test objective using Text_IO output (unless the body of Report has been modified to do something else). After each section of test code, there is normally a check of post conditions. The if statement in this skeleton is such a check; unexpected results produce a call to Report.Failed. The sequence of test code / check of results may be repeated several times in a single test. Finally, there is a call to Report.Result that will print the test result to Text_IO output. Often, but not always, this structure is enclosed in a declare block.
One or more calls to Report.Failed will report a result of "FAILED" and a brief suggestion of the likely reason for that result.
More complex tests may include calls to Report.Failed in the code other than in the main program, and therefore exhibit the following format for the main procedure:
with Report;
procedure Testname is
   <declarations>
begin
   Report.Test ("Testname", "Description ...");
   ...
   Subtest_Call;
   ...
   Report.Result;
end Testname;
Fail conditions are detected in subprograms (or tasks) and Report.Failed is called within them.
Occasionally, as a test is running, it will determine that it is not applicable. In such a case, it will call Report.Not_Applicable that will report a result of "NOT_APPLICABLE" (unless there is also a call to Report.Failed).
Often, a test calls one of the functions Report.Ident_Int or Report.Ident_Bool to obtain a value that could be provided as a literal. These functions are intended to prevent optimizers from eliminating certain sections of test code. The ACATS suite has no intention of trying to discourage the application of optimizer technology, however satisfactory testing of language features often requires the presence and execution of specific lines of test code. Report.Ident_Int and Report.Ident_Bool are structured so that they can be modified when needed to defeat optimizer advances.
Class B tests may be structured differently. Since they are not executable, they normally do not include calls to Report.Test or Report.Result (since those lines of code would have no output effect). Instead, intentional errors are coded that invoke specific legality rules. The source code includes comments that document expected compiler results. Legal constructs may also be included in B class tests. Constructs that are allowed by the legality rules are marked -- OK; constructs that are disallowed are marked -- ERROR:. (Some additional markings can also be used, see 4.2.2.) There is usually a brief indication of the nature of an intentional error on the same line or the line following a comment. The indications of expected results are approximately right justified to the code file margin, about column 79, for quick visual identification.
Class L tests are multifile tests with illegalities that should be detected at bind time. They are generally structured like class C tests, often with calls to Report.Test and Report.Result, but they are not expected to execute.

Contents   Index   References   Previous   Next