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 EDNA test Case module ...
31
32 a TestCase is a single test, either an unit test or an execution test.
33 """
34
35 __authors__ = "Marie-Francoise Incardona, Olof Svensson, Jerome Kieffer"
36 __contact__ = "svensson@esrf.eu"
37 __license__ = "LGPLv3+"
38 __copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
39 __date__ = "20120216"
40
41 from EDTest import EDTest
42 from EDVerbose import EDVerbose
43 from EDUtilsTest import EDUtilsTest
44 from EDUtilsPath import EDUtilsPath
45
46
48 """
49 Test case class
50 """
51
53 EDTest.__init__(self, _strTestName)
54 self.__strTestSuiteName = None
55 self.__strTestsHome = None
56 self.__strTestsDataHome = None
57 self.__strTestsDataImagesHome = None
58 self.__strReasonForNotBeingExecuted = ""
59 self.__bIsExecuted = False
60 self.__iNumberTestMethodSuccess = 0
61 self.__iNumberTestMethodFailure = 0
62 self.__dictMethodFailureMessages = {}
63
64
114
115
116
117 - def postProcess(self):
118 """
119 Writes out a summary of the test case.
120 """
121 if self.__bIsExecuted:
122 EDVerbose.unitTest("-------------------------------------------------------------------")
123 EDVerbose.unitTest("Result for %s" % self.getClassName())
124 EDVerbose.unitTest()
125 EDVerbose.unitTest("Total number of test methods : %d" % self.getNumberOfTests())
126 EDVerbose.unitTest("Number of SUCCESS : %d" % self.__iNumberTestMethodSuccess)
127 EDVerbose.unitTest("Number of FAILURE : %d" % self.__iNumberTestMethodFailure)
128 if self.__dictMethodFailureMessages != {}:
129 EDVerbose.unitTest("")
130 EDVerbose.unitTest("List of test methods ending with failure:")
131 for strMethodName in self.__dictMethodFailureMessages:
132 EDVerbose.unitTest(" %s :" % strMethodName.split(".")[1])
133 EDVerbose.unitTest(" %s" % self.__dictMethodFailureMessages[strMethodName])
134 EDVerbose.unitTest()
135 EDVerbose.unitTest("Runtime : %.3f [s]" % self.getRunTime())
136 EDVerbose.unitTest("===================================================================")
137 else:
138 EDVerbose.unitTest()
139 EDVerbose.unitTest("Test case %s not executed :" % self.getClassName())
140 EDVerbose.unitTest(self.__strReasonForNotBeingExecuted)
141 EDVerbose.unitTest()
142 EDVerbose.unitTest("===================================================================")
143
144
146 """
147 This method returns a dictionary with the failure messages:
148 Key : Name of the test method
149 Value : Failure message
150 @return: MethodFailureMessages
151 @rtype: dict
152 """
153 return self.__dictMethodFailureMessages
154
155
157 """
158 Used by EDTestSuite: Sets the name of the test suite invoking the test case.
159 @param _strTestSuiteName: TestSuiteName
160 @type _strTestSuiteName: string
161 """
162 self.__strTestSuiteName = _strTestSuiteName
163
164
165
167 """
168 Returns the name of the test suite invoking the test case.
169 None if not inviked by a test suite.
170 @return: TestSuiteName
171 @rtype: string
172 """
173 return self.__strTestSuiteName
174
175
177 """
178 Sets a string describing why the test case shouldn't be executed.
179 For example : missing configuration file.
180 If the string is not empty, the test case is not executed.
181 @param _strValue: ReasonForNotBeingExecuted
182 @type _strValue: string
183 """
184 self.__strReasonForNotBeingExecuted = _strValue
185
186
188 """
189 Returns a string describing why the test case shouldn't be executed.
190 For example : missing configuration file.
191 If the string is not empty, the test case is not executed.
192 @return: ReasonForNotBeingExecuted
193 @rtype: string
194 """
195 return self.__strReasonForNotBeingExecuted
196
197
199 """
200 Returns the Test home directory
201 @return: TestsHome
202 @rtype: string
203 """
204 return EDUtilsPath.EDNA_TESTS
205
206
208 """
209 Returns the Test data home directory
210 @return: TestsDataHome
211 @rtype: string
212 """
213 return EDUtilsPath.EDNA_TESTDATA
214
215
217 """
218 Returns the Test data home directory
219 @return: TestsDataImagesHome
220 @rtype: string
221 """
222 return EDUtilsPath.EDNA_TESTIMAGES
223
224
225
227 """
228 The number of successful test methods.
229 @return: NumberTestMethodSuccess
230 @rtype: integer
231 """
232 return self.__iNumberTestMethodSuccess
233
234
236 """
237 The number of test methods executed with failure.
238 @return: NumberTestMethodFailure
239 @rtype: integer
240 """
241 return self.__iNumberTestMethodFailure
242
243
245 """
246 Returns True if the test case was executed.
247 @return: IsExecuted
248 @rtype: boolean
249 """
250 return self.__bIsExecuted
251