1 | ------------------------------------------------------------------------------ |
---|---|
2 | -- -- |
3 | -- GNAT COMPILER COMPONENTS -- |
4 | -- -- |
5 | -- A U N I T . T E S T _ F I X T U R E S -- |
6 | -- -- |
7 | -- S p e c -- |
8 | -- -- |
9 | -- -- |
10 | -- Copyright (C) 2008-2011, AdaCore -- |
11 | -- -- |
12 | -- GNAT is free software; you can redistribute it and/or modify it under -- |
13 | -- terms of the GNU General Public License as published by the Free Soft- -- |
14 | -- ware Foundation; either version 3, or (at your option) any later ver- -- |
15 | -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- |
16 | -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- |
17 | -- or FITNESS FOR A PARTICULAR PURPOSE. -- |
18 | -- -- |
19 | -- As a special exception under Section 7 of GPL version 3, you are granted -- |
20 | -- additional permissions described in the GCC Runtime Library Exception, -- |
21 | -- version 3.1, as published by the Free Software Foundation. -- |
22 | -- -- |
23 | -- You should have received a copy of the GNU General Public License and -- |
24 | -- a copy of the GCC Runtime Library Exception along with this program; -- |
25 | -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- |
26 | -- <http://www.gnu.org/licenses/>. -- |
27 | -- -- |
28 | -- GNAT is maintained by AdaCore (http://www.adacore.com) -- |
29 | -- -- |
30 | ------------------------------------------------------------------------------ |
31 | |
32 | -- <description> |
33 | -- A Test_Fixture is used to provide a common environment for a set of test |
34 | -- cases. |
35 | -- |
36 | -- To define a test case from a test fixture, see AUnit.Test_Caller. |
37 | -- |
38 | -- Each test runs in its own fixture so there can be no side effects among |
39 | -- test runs. |
40 | -- |
41 | -- Here is an example: |
42 | -- |
43 | -- <code> |
44 | -- package Math_Test is |
45 | -- Type Test is new AUnit.Test_Fixtures.Test_Fixture with record |
46 | -- M_Value1 : Integer; |
47 | -- M_Value2 : Integer; |
48 | -- end record; |
49 | -- |
50 | -- procedure Set_Up (T : in out Test); |
51 | -- |
52 | -- procedure Test_Addition (T : in out Test); |
53 | -- |
54 | -- end Math_Test; |
55 | -- |
56 | -- package body Math_Test is |
57 | -- |
58 | -- procedure Set_Up (T : in out Test) is |
59 | -- begin |
60 | -- T.M_Value1 := 2; |
61 | -- T.M_Value2 := 3; |
62 | -- end Set_Up; |
63 | -- |
64 | -- procedure Test_Addition (T : in out Test) is |
65 | -- begin |
66 | -- Assert (T.M_Value1 + T.M_Value2 = 5, |
67 | -- "Incorrect addition for integers"); |
68 | -- end Test_Addition; |
69 | -- |
70 | -- end Math_Test; |
71 | -- </code> |
72 | -- </description> |
73 | |
74 | with AUnit.Assertions; |
75 | |
76 | package AUnit.Test_Fixtures is |
77 | |
78 | type Test_Fixture is new AUnit.Assertions.Test with private; |
79 | |
80 | procedure Set_Up (Test : in out Test_Fixture); |
81 | -- Set up performed before each test case |
82 | |
83 | procedure Tear_Down (Test : in out Test_Fixture); |
84 | -- Tear down performed after each test case |
85 | |
86 | private |
87 | |
88 | type Test_Fixture is new AUnit.Assertions.Test with null record; |
89 | |
90 | end AUnit.Test_Fixtures; |