Esempio n. 1
0
    def __init__(self, tcObj, startStatus, strategy):
        self.startStatus = startStatus
        self.tlog = tcObj.tlog
        self.strategy = "product" if strategy == "all" else strategy
        self.isAcceptHandler = tcObj.__isAccept__
        self.isContinueHandler = tcObj.__isContinue__
        self.getStepArgHandler = tcObj.__getArgList__
        self.isDebug = tcObj.__isDebug__()

        testSteps = TValueGroup({})
        for sFunName in [
                funName for funName in dir(tcObj)
                if not funName.startswith("__")
        ]:
            sFun = eval("tcObj.%s" % sFunName)

            if (hasattr(sFun, '__name__')
                    and sFun.__name__ == 'stepDecorator'):
                sFunStatus = sFun()
                testSteps[sFunName] = {
                    'or': sFunStatus[0].split(','),
                    'to': sFunStatus[1],
                    'repeat': sFunStatus[2],
                    'cover': {}
                }

        self.testSteps = testSteps
Esempio n. 2
0
 def getTCInfo(self, tcName):
     if not self.tcInfos.keys().__contains__(tcName):
         tcInfo = TValueGroup({})
         tcInfo.Orders = None
         tcInfo.isTested = False
         self.tcInfos[tcName] = tcInfo
     return self.tcInfos[tcName]
Esempio n. 3
0
 def __init__(self):
     self.runModeEnum = {'slook':-22, 'scenario':-21, 'param':-11, 'look':-10, 'show':-9, 'debug':0, 'run':9, 'rerun':10, 'stop':-9}
     self.testResInfo = ['Passed', 'Warned', 'Failed', 'NotRun']
     self.tlog = TestLoggerFactory()
     self.tprop = IniConfigure("mtest.ini")
     self.tassert = TestAssert(self.tlog)
     self.tcInfos = TValueGroup({})
     self.init()
Esempio n. 4
0
    def _getNextParam(self):
        if self.isList:
            strategyParam = TValueGroup({})
        else:
            strategyParam = TValueGroup(self.tParam, True, isDeepClone=True)
        strategyParam.pIndex = self.curParamIndex
        strategyParam.paramName = None
        strategyParam.orderNum = self.curOrderNum

        self.__renderParam__(strategyParam)

        if self.isPureNum:
            self.curOrderNum = self.gcombSp.getNextPureOrderNum(
                self.curOrderNum)
        else:
            self.curOrderNum += 1

        return strategyParam
Esempio n. 5
0
    def __init__(self, tParam, whereCondition, group):

        self.tParam = TValueGroup(tParam)
        self.condition = ObjOperation.tryGetVal(whereCondition, "condition",
                                                None)
        self.combSp = self.__combParam__(tParam, whereCondition, group)

        self.totalParams = self.combSp.getTotalNum()
        self.curOrderNum = 0
        self.curParamIndex = 0
Esempio n. 6
0
 def addModelCls(self, modelClass, testModule, testName, imports, testOrder,
                 searchKey):
     tcInfo = self.tc.getTCInfo(modelClass.__name__)
     for caseFun in dir(modelClass):
         if not MTConst.sysFunReg.isMatch(caseFun):
             testCaseInfo = TValueGroup({})
             testCaseInfo.Name = caseFun
             tcInfo[caseFun] = {}
     tcInfo.Module = testModule
     tcInfo.Name = testName if testName != None else modelClass.__name__
     tcInfo.Imports = imports
     tcInfo.Orders = testOrder
     tcInfo.SearchKey = searchKey
Esempio n. 7
0
    def __addPathToArgPathContainer(self, argPathContainer, testPath,
                                    repeatCount):
        pathParam = TValueGroup({})
        stepIndexList = []
        stepIndexToCombIndex = {}
        isCondCover = self.strategy == "condition"
        isEdgeCover = self.strategy == "edge" or self.strategy == "condEdge" or isCondCover
        notCondCover = self.strategy == "path" or self.strategy == "edge" or self.strategy == 'available'

        noNewEdge, stepIndex, combIndex = self.__prepareTestPath(
            testPath, pathParam, stepIndexList, stepIndexToCombIndex,
            isEdgeCover, isCondCover)
        if isEdgeCover and noNewEdge:
            return

        pathCovered = False
        stepArg = CombineSingleParam(pathParam, {
            'combine': stepIndexList,
            'strategy': self.strategy
        }, None)
        while True:
            pathArg = stepArg.nextParam()
            if pathArg == None:
                break
            acceptRes, acceptStepIndex = self.__isTestPathAccept(
                testPath, pathArg)
            if acceptRes <= 9:
                addTestPath = testPath
                if stepIndex > acceptStepIndex:
                    addTestPath = list(testPath)
                    delStepIndex = stepIndex
                    while delStepIndex > acceptStepIndex:
                        addTestPath.__delitem__(delStepIndex)
                        pathArg.__delitem__(delStepIndex)
                        delStepIndex -= 1
                pathCovered = True
                argPathContainer.append({
                    'path': addTestPath,
                    'accept': acceptRes,
                    'arg': pathArg
                })
                if notCondCover:
                    break

            addCombIndex = ObjOperation.tryGetVal(stepIndexToCombIndex,
                                                  acceptStepIndex, combIndex)
            if addCombIndex < combIndex:
                stepArg.toNextParamArg(addCombIndex)

        if isEdgeCover and pathCovered:
            self.__coverTestPath(testPath)
Esempio n. 8
0
 def diffJson(self, jsonStr, jsonStr2):
     return "%s\n%s" % ObjOperation.jsonEqual(
         TValueGroup(jsonStr).__prop__,
         TValueGroup(jsonStr2).__prop__)
Esempio n. 9
0
 def __init__(self):
     self.property = tprop
     self.tassert = tassert
     self.tlog = tlog
     self.param = TValueGroup({})
Esempio n. 10
0
 def testtvg(self):
     self.tlog.info(JsonParser().toStr({'a': TValueGroup({'b': 1})}))