Changes between Version 25 and Version 26 of GSoC/2014/TestingFrameworkForGRASS
- Timestamp:
- 05/30/14 11:42:39 (11 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
GSoC/2014/TestingFrameworkForGRASS
v25 v26 169 169 This describes how `unittest` is doing it and we want to use as many classes (directly or by inheriting) from `unittest` as possible, so it will be probably also our system. 170 170 171 Loading of tests: 172 173 {{{ 171 Loading of tests (pseudo code): 172 173 {{{ 174 #!python 174 175 # finds all test methods of a given test case and creates test suite 175 # suite class will get a list of instances of test case class with amethod name (test method)176 # getTestCaseNames ==test method names177 TestLoader.loadTestsFromTestCase() 178 176 # test suite class will get a list of instances of test case class, each with one method name (test method) 177 # testCaseNames contains test method names 178 def TestLoader.loadTestsFromTestCase(testCaseClass): 179 testCaseNames = filter(isTestMethod, dir(testCaseClass)) 179 180 loaded_suite = self.suiteClass(map(testCaseClass, testCaseNames)) 180 181 181 # finds all test cases in themodule/script182 TestLoader.loadTestsFromModule() 182 # finds all test cases in a module/script 183 def TestLoader.loadTestsFromModule(module): 183 184 for each object in module: 184 185 if isinstance(obj, type) and issubclass(obj, case.TestCase): 185 186 tests.append(self.loadTestsFromTestCase(obj)) 186 187 suiteClass = suite.TestSuite 187 188 tests = self.suiteClass(tests) 188 189 189 # finds all tests passes them to test runner 190 TestProgram.runTests() 190 # finds all tests (by direct import of what was specified or test discovery) 191 # passes found tests to test runner 192 def TestProgram.runTests(): 191 193 self.test = self.testLoader.loadTestsFromModule(self.module) 192 194 self.result = testRunner.run(self.test) 193 195 194 196 # triggers the top level test suite 195 TextTestRunner.run(test) 197 def TextTestRunner.run(test): 196 198 test(result) 197 199 }}} 198 200 199 Running of tests (test suite can contain test suite or test case instances): 200 201 {{{ 201 Running of tests (pseudo code): 202 203 {{{ 204 #!python 202 205 # invokes the separate tests 203 206 # does setup and teardown for class 204 TestSuite.run(result) 207 # note that test suite can contain test suite or test case instances 208 def TestSuite.run(result): 205 209 for each test: 206 210 test(result) 207 211 208 212 # runs the test method and adds the information to the result 209 # does setup and teardown for instance 210 TestCase.run(result) 213 # does setup and teardown for an test case instance 214 def TestCase.run(result): 215 ... 211 216 }}} 212 217