Changes between Version 25 and Version 26 of GSoC/2014/TestingFrameworkForGRASS


Ignore:
Timestamp:
May 30, 2014, 11:42:39 AM (10 years ago)
Author:
wenzeslaus
Comment:

improve test internal invocation desc

Legend:

Unmodified
Added
Removed
Modified
  • GSoC/2014/TestingFrameworkForGRASS

    v25 v26  
    169169This 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.
    170170
    171 Loading of tests:
    172 
    173 {{{
     171Loading of tests (pseudo code):
     172
     173{{{
     174#!python
    174175# 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 a method name (test method)
    176 # getTestCaseNames == test method names
    177 TestLoader.loadTestsFromTestCase()
    178         testCaseNames = filter(isTestMethod, dir(testCaseClass))
     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
     178def TestLoader.loadTestsFromTestCase(testCaseClass):
     179    testCaseNames = filter(isTestMethod, dir(testCaseClass))
    179180    loaded_suite = self.suiteClass(map(testCaseClass, testCaseNames))
    180181
    181 # finds all test cases in the module/script
    182 TestLoader.loadTestsFromModule()
     182# finds all test cases in a module/script
     183def TestLoader.loadTestsFromModule(module):
    183184    for each object in module:
    184185        if isinstance(obj, type) and issubclass(obj, case.TestCase):
    185                         tests.append(self.loadTestsFromTestCase(obj))
     186            tests.append(self.loadTestsFromTestCase(obj))
    186187    suiteClass = suite.TestSuite
    187188    tests = self.suiteClass(tests)
    188189
    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
     192def TestProgram.runTests():
    191193    self.test = self.testLoader.loadTestsFromModule(self.module)
    192194    self.result = testRunner.run(self.test)
    193195
    194196# triggers the top level test suite
    195 TextTestRunner.run(test)
     197def TextTestRunner.run(test):
    196198    test(result)
    197199}}}
    198200
    199 Running of tests (test suite can contain test suite or test case instances):
    200 
    201 {{{
     201Running of tests (pseudo code):
     202
     203{{{
     204#!python
    202205# invokes the separate tests
    203206# does setup and teardown for class
    204 TestSuite.run(result)
     207# note that test suite can contain test suite or test case instances
     208def TestSuite.run(result):
    205209    for each test:
    206210        test(result)
    207211
    208212# 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
     214def TestCase.run(result):
     215     ...
    211216}}}
    212217