Esempio n. 1
0
    def __init__(self):
        self.testTime = datetime.datetime.now()
        a = [
            x
            for x in os.listdir(testConf.uiTestScriptDir)
            if ((re.search(r"\.py$", x)) and not (re.match(r"__init__\.py", x)))
        ]
        self.listMoudle = [x.split(".")[0] for x in a]

        def delRunScript(listMoudle, delList):
            # 返回差集
            return [i for i in listMoudle if i not in delList]

        self.listMoudle = delRunScript(self.listMoudle, ["LoginPage", "process", "processOne"])
        print u"需要执行的测试有%s" % (self.listMoudle)
        sys.path.insert(0, testConf.uiTestScriptDir)
        logger.info(u" ")
        logger.info(u"本次执行测试 %s" % (a))
        # 下面包含了一些全局的信息,包括总共需要执行了多少脚本,实际执行了多少脚本成功执行的脚本的个数,失败执行的脚本个数
        self.needRunCount = len(self.listMoudle)
        self.runCount = 0
        self.failCount = 0
        self.sucessCount = 0
Esempio n. 2
0
 def runTest(self):
     for i in self.listMoudle:
         logger.info(u"执行%s" % (i))
         a = imp.find_module(i)
         mod_all = imp.load_module(i, a[0], a[1], a[2])
         print mod_all
         uiTest = mod_all.uiTest
         print uiTest
         # uiTest.runTest()
         self.runCount += 1
         tmp = uiTest.getRes()
         print tmp
         tmp = json.loads(tmp)
         if tmp["res"] == 0:
             self.failCount += 1
             self.__addEmailInfo(tmp, "%s.py" % (i))
             logger.info(u"ui测试%s失败" % (i))
         else:
             self.sucessCount += 1
             logger.info(u"ui测试%s成功" % (i))