TestCenter Reference
TestCaseGeneric.py
Go to the documentation of this file.
2# Copyright 2009, MeVis Medical Solutions AG
3#
4# The user may use this file in accordance with the license agreement provided with
5# the Software or, alternatively, in accordance with the terms contained in a
6# written agreement between the user and MeVis Medical Solutions AG.
7#
8# For further information use the contact form at https://www.mevislab.de/contact
9#
10
13
14import mevis
15from .TestCase import TestCase
16from TestSupport.TestHelper import TestHelper
17
18
20 """TestCase superclass for generic testing"""
21
22 def __init__(self, testCaseName, moduleName=None):
23 self._moduleName = moduleName
24 TestCase.__init__(self, testCaseName)
25
26 def getType(self):
27 return "GenericTestCase"
28
29 def run(self, xmlNode):
30 """Prior to running the actual test the module name is set to the result node."""
31 if not self._moduleName:
32 raise Exception("No module name set for test %s." % self._testCaseName_testCaseName)
33 self._testHelper.setModuleName(self._moduleName)
34 TestCase.run(self, xmlNode)
35 self._testHelper.setModuleName(None)
36
37 def __testModule(self, moduleName):
38 """Verify whether module should be tested or not.
39 If a generic test has a method "testModule" it is called. The result must be a boolean value
40 that indicates whether the given module should be tested. The default return value is True.
41 """
42 if "testModule" in self._ctx.callableFunctions():
43 return self._ctx.call(
44 "testModule",
45 [
46 moduleName,
47 ],
48 )
49 return True
50
51 def getName(self):
52 """Return the name of the test case."""
53 return "%s::%s" % (self._testCaseName_testCaseName, self._moduleName)
54
55 def getModulesToTest(self, moduleList, packageList):
56 """Get the list of modules to test."""
57 availableModuleList = []
58
59 for packageIdentifier in packageList:
60 availableModuleList.extend(mevis.MLAB.allModulesForPackageIdentifier(packageIdentifier))
61
62 # Testing myself wouldn't be a good idea (recursive adding of module is not supported).
63 testerName = TestHelper.getInstance().getGlobalContext().name
64 if testerName in availableModuleList:
65 availableModuleList.remove(testerName)
66
67 modulesToTest = []
68 modulesNotToTest = []
69 for moduleName in moduleList:
70 if moduleName in availableModuleList:
71 if self.__testModule(moduleName):
72 modulesToTest.append(moduleName)
73 else:
74 modulesNotToTest.append(moduleName)
75 return modulesToTest, modulesNotToTest
TestCase superclass for generic testing.
getName(self)
Return the name of the test case.
run(self, xmlNode)
Prior to running the actual test the module name is set to the result node.
getModulesToTest(self, moduleList, packageList)
Get the list of modules to test.
__init__(self, testCaseName, moduleName=None)
Initialize the test case.
getType(self)
Return the type of this test case (generic or functional).
The superclass for the different test case categories.
Definition TestCase.py:171