1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- A U N I T . T E S T _ C A L L E R --
-- --
-- S p e c --
-- --
-- --
-- Copyright (C) 2008-2011, AdaCore --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT is maintained by AdaCore (http://www.adacore.com) --
-- --
------------------------------------------------------------------------------
-- <description>
-- A Test caller provides access to a test case type based on a test fixture.
-- Test callers are useful when you want to run individual test or add it to
-- a suite.
-- Test callers invoke only one Test (i.e. test method) on one Fixture of a
-- AUnit.Test_Fixtures.Test_Fixture.
--
-- Here is an example:
--
-- <code>
-- package Math_Test is
-- Type Test is new AUnit.Test_Fixtures.Test_Fixture with record
-- M_Value1 : Integer;
-- M_Value2 : Integer;
-- end record;
--
-- procedure Set_Up (T : in out Test);
--
-- procedure Test_Addition (T : in out Test);
-- procedure Test_Subtraction (T : in out Test);
--
-- end Math_Test;
--
-- function Suite return AUnit.Test_Suites.Test_Suite_Access is
-- package Caller is new AUnit.Test_Caller (Math_Test.Test);
-- The_Suite : AUnit.Test_Suites.Test_Suite_Access :=
-- new AUnit.Test_Suites.Test_Suite;
-- begin
-- The_Suite.Add_Test
-- (Caller.Create ("Test Addition on integers",
-- Math_Test.Test_Addition'Access));
-- The_Suite.Add_Test
-- (Caller.Create ("Test Subtraction on integers",
-- Math_Test.Test_Subtraction'Access));
-- return The_Suite;
-- end Suite;
-- </code>
-- </description>
with AUnit.Simple_Test_Cases;
with AUnit.Test_Fixtures;
generic
type Test_Fixture is new AUnit.Test_Fixtures.Test_Fixture with private;
package AUnit.Test_Caller is
type Test_Case is new AUnit.Simple_Test_Cases.Test_Case with private;
type Test_Case_Access is access all Test_Case'Class;
type Test_Method is access procedure (Test : in out Test_Fixture);
function Create
(Name : String;
Test : Test_Method) return Test_Case_Access;
-- Return a test case from a test fixture method, reporting the result
-- of the test using the Name parameter.
procedure Create
(TC : out Test_Case'Class;
Name : String;
Test : Test_Method);
-- Initialize a test case from a test fixture method, reporting the result
-- of the test using the Name parameter.
function Name (Test : Test_Case) return Message_String;
-- Test case name
procedure Run_Test (Test : in out Test_Case);
-- Perform the test.
procedure Set_Up (Test : in out Test_Case);
-- Set up performed before each test case
procedure Tear_Down (Test : in out Test_Case);
-- Tear down performed after each test case
private
type Fixture_Access is access all Test_Fixture;
pragma No_Strict_Aliasing (Fixture_Access);
type Test_Case is new AUnit.Simple_Test_Cases.Test_Case with record
Fixture : Fixture_Access;
Name : Message_String;
Method : Test_Method;
end record;
end AUnit.Test_Caller;
|