1 |
# ***************************************************************************** |
2 |
# * * |
3 |
# * COPYRIGHT ACcESS 2004 - All Rights Reserved * |
4 |
# * * |
5 |
# * This software is the property of ACcESS. No part of this code * |
6 |
# * may be copied in any form or by any means without the expressed written * |
7 |
# * consent of ACcESS. Copying, use or modification of this software * |
8 |
# * by any unauthorised person is illegal unless that person has a software * |
9 |
# * license agreement with ACcESS. * |
10 |
# * * |
11 |
# ***************************************************************************** |
12 |
# |
13 |
# Skeleton for unit test files |
14 |
# Text outside of known blocks is ignored and can be used for comments |
15 |
# Keywords must be the first non-blank text on a line |
16 |
# Blocks cannot be embedded in other blocks (they will just be ignored) |
17 |
# |
18 |
# The Message block contains text to be output |
19 |
# The Usage block begins with a "BeginMessage" keyword and ends with a |
20 |
# "EndMessage" keyword |
21 |
# The Message block is processed when it is found and uses whatever |
22 |
# replacements are in place at the current time |
23 |
# |
24 |
BeginMessage |
25 |
Processing Unit Test generation skeleton |
26 |
EndMessage |
27 |
|
28 |
# |
29 |
# The Usage block contains the text of the usage message to display if |
30 |
# too few arguments are specified on the command line |
31 |
# The Usage block begins with a "BeginUsage" keyword and ends with a |
32 |
# "EndUsage" keyword |
33 |
# The BeginUsage has a single argument - the number of arguments required |
34 |
# |
35 |
BeginUsage 2 |
36 |
UnitTest skeleton expects two arguments <ClassName> and <ClassNamespace> |
37 |
|
38 |
<ClassName> is the name of the class being tested |
39 |
<ClassNamespace> is the namespace containing the tested class |
40 |
|
41 |
EndUsage |
42 |
|
43 |
# |
44 |
# The replacements block defines the edit replacements to be performed |
45 |
# The token to be replaced must be containined inside angle brackets |
46 |
# (both in the replacement token definition and the text to be edited) |
47 |
# The replacement text is defined by special keywords |
48 |
# Valid keywords are |
49 |
# arg:n (where n is a zero based integer) |
50 |
# token will be replaced with the text from input argument n |
51 |
# date:yyyymmdd |
52 |
# token will be replaced with the current date in YYYYMMDD format |
53 |
# Each replacement block completely replaces any previous replacement block |
54 |
# no replacement definitions from the previous block are carried forward |
55 |
# The replacements block begins with a BeginReplacements keyword and |
56 |
# ends with a EndReplacements keyword |
57 |
# |
58 |
BeginReplacements |
59 |
<ClassName> arg:0 |
60 |
<ClassNamespace> arg:1 |
61 |
<YYYYMMDD> date:yyyymmdd |
62 |
EndReplacements |
63 |
# |
64 |
# The following message will have replacements substituted |
65 |
# |
66 |
BeginMessage |
67 |
Classname : <ClassName> |
68 |
Class Namespace : <ClassNamespace> |
69 |
EndMessage |
70 |
# |
71 |
# The FileCheck block checks the specified files do not exist in |
72 |
# the current directory - if they do processing will stop |
73 |
# The file names will be processed for replacements |
74 |
# The FileCheck block begins with the BeginFileCheck keyword and |
75 |
# ends with the EndFileCheck keyword |
76 |
# |
77 |
BeginFileCheck |
78 |
<ClassName>Test.cpp |
79 |
<ClassName>Test.mk |
80 |
<ClassName>TestCase.cpp |
81 |
<ClassName>TestCase.h |
82 |
EndFileCheck |
83 |
# |
84 |
# The file block defines the text of a file to be generated |
85 |
# The file block begins with a BeginFile keyword and ends with an |
86 |
# EndFile keyword |
87 |
# The BeginFile keyword contains the name of the file as an argument |
88 |
# the file name is edited with the current replacement set |
89 |
# |
90 |
BeginFile <ClassName>Test.cpp |
91 |
/* |
92 |
***************************************************************************** |
93 |
* * |
94 |
* COPYRIGHT ACcESS - All Rights Reserved * |
95 |
* * |
96 |
* This software is the property of ACcESS. No part of this code * |
97 |
* may be copied in any form or by any means without the expressed written * |
98 |
* consent of ACcESS. Copying, use or modification of this software * |
99 |
* by any unauthorised person is illegal unless that person has a software * |
100 |
* license agreement with ACcESS. * |
101 |
* * |
102 |
***************************************************************************** |
103 |
*/ |
104 |
#include "<ClassName>TestCase.h" |
105 |
#include "CppUnitTest/TestRunner.h" |
106 |
|
107 |
using namespace CppUnitTest; |
108 |
|
109 |
int main(int argc, char **argv) { |
110 |
// |
111 |
// object which runs all of the tests |
112 |
TestRunner runner; |
113 |
// |
114 |
// add the RangeTestCase suite of tests to the runner |
115 |
runner.addTest ("<ClassName>", <ClassName>TestCase::suite()); |
116 |
|
117 |
// actually run the unit tests. |
118 |
runner.run (argc, argv); |
119 |
return 0; |
120 |
} |
121 |
|
122 |
EndFile |
123 |
|
124 |
BeginFile <ClassName>Test.mk |
125 |
DEFAULT_TARGET := <ClassName>Test.exe |
126 |
L_SRC_DIR := . |
127 |
PACKAGES := CppUnitTest Utils |
128 |
include $(ESYS_ROOT)/make/Makefile.default |
129 |
|
130 |
EndFile |
131 |
BeginFile <ClassName>TestCase.cpp |
132 |
/* |
133 |
***************************************************************************** |
134 |
* * |
135 |
* COPYRIGHT ACcESS - All Rights Reserved * |
136 |
* * |
137 |
* This software is the property of ACcESS. No part of this code * |
138 |
* may be copied in any form or by any means without the expressed written * |
139 |
* consent of ACcESS. Copying, use or modification of this software * |
140 |
* by any unauthorised person is illegal unless that person has a software * |
141 |
* license agreement with ACcESS. * |
142 |
* * |
143 |
***************************************************************************** |
144 |
*/ |
145 |
#include "<ClassNamespace>/<ClassName>.h" |
146 |
#include "<ClassName>TestCase.h" |
147 |
|
148 |
using namespace CppUnitTest; |
149 |
|
150 |
void <ClassName>TestCase::setUp() { |
151 |
// |
152 |
// This is called before each test is run |
153 |
|
154 |
} |
155 |
|
156 |
void <ClassName>TestCase::tearDown() { |
157 |
// |
158 |
// This is called after each test has been run |
159 |
|
160 |
} |
161 |
|
162 |
void <ClassName>TestCase::testAll() { |
163 |
// |
164 |
// The test code may be entered here |
165 |
// There is nothing special about the function name, it may be renamed to |
166 |
// something more suitable. |
167 |
// As many test methods as desired may be added. |
168 |
|
169 |
} |
170 |
|
171 |
TestSuite* <ClassName>TestCase::suite () |
172 |
{ |
173 |
// |
174 |
// create the suite of tests to perform. |
175 |
TestSuite *testSuite = new TestSuite ("<ClassName>TestCase"); |
176 |
|
177 |
testSuite->addTest (new TestCaller< <ClassName>TestCase>("testAll",&<ClassName>TestCase::testAll)); |
178 |
return testSuite; |
179 |
} |
180 |
|
181 |
EndFile |
182 |
BeginFile <ClassName>TestCase.h |
183 |
/* |
184 |
***************************************************************************** |
185 |
* * |
186 |
* COPYRIGHT ACcESS - All Rights Reserved * |
187 |
* * |
188 |
* This software is the property of ACcESS. No part of this code * |
189 |
* may be copied in any form or by any means without the expressed written * |
190 |
* consent of ACcESS. Copying, use or modification of this software * |
191 |
* by any unauthorised person is illegal unless that person has a software * |
192 |
* license agreement with ACcESS. * |
193 |
* * |
194 |
***************************************************************************** |
195 |
*/ |
196 |
#if !defined <ClassName>TestCase_<YYYYMMDD>_H |
197 |
#define <ClassName>TestCase_<YYYYMMDD>_H |
198 |
|
199 |
#include "CppUnitTest/TestCase.h" |
200 |
#include "CppUnitTest/TestSuite.h" |
201 |
#include "CppUnitTest/TestCaller.h" |
202 |
|
203 |
class <ClassName>TestCase : public CppUnitTest::TestCase |
204 |
{ |
205 |
public: |
206 |
|
207 |
// |
208 |
// setUp is called before each test method to set up test state |
209 |
void setUp(); |
210 |
// |
211 |
// tearDown is called after each test method is called. |
212 |
void tearDown(); |
213 |
|
214 |
// |
215 |
// A test method must return void and have no arguments |
216 |
// <ClassName> class |
217 |
void testAll(); |
218 |
|
219 |
<ClassName>TestCase (std::string name) : TestCase (name) {} |
220 |
~<ClassName>TestCase() {} |
221 |
// |
222 |
// |
223 |
// return the suite of tests to perform |
224 |
// |
225 |
static CppUnitTest::TestSuite* suite (); |
226 |
}; |
227 |
|
228 |
#endif |
229 |
EndFile |
230 |
|
231 |
BeginMessage |
232 |
Completed generating Unit Test files |
233 |
EndMessage |