示例#1
0
文件: main.py 项目: gaga128/AutoTest
def run():
    if sh.cell_value(0, ncols - 1) == 'Expectresult':
        getCase.runcase(casepath)

    else:
        runFirstresult = getFirstResults.runcase(casepath, sheetname1)
        writeExcelresult.writeResult(runFirstresult, resultpath, sheetname1)
示例#2
0
def run():
    runFirstresult = getCasesResults.runcase(casepath, casesheet, caseresult)
    writeExcelresult.writeResult(runFirstresult, casepath, caseresult)

    runFirstnullresult = getAutoCasesResults.createcase(
        casepath, Autocasesheet, Autocaseresult, Speparamlist)
    writeExcelresult.writeResult(runFirstnullresult, casepath, Autocaseresult)
示例#3
0
def Singlerun(casepath):
    runFirstresult = getCasesResults.runcase(
        casepath, casesheet, caseresult)  ####手动配置case生成case结果及对比
    writeExcelresult.writeResult(runFirstresult, casepath, caseresult)
    runFirstnullresult = getAutoCasesResults.createcase(
        casepath, Autocasesheet, Autocaseresult,
        Speparamlist)  ####自动生成case结果及对比
    writeExcelresult.writeResult(runFirstnullresult, casepath, Autocaseresult)
    runresult = getParam.createtypecase(casepath, Autocasesheet,
                                        Autotyperesult, typelist)
    Execution.Executionmode2(runresult, casepath, Autotyperesult)
示例#4
0
def runAll(allCasepath):
    filelist = readAllExcels.readfile(allCasepath)
    for i in range(0, len(filelist)):
        testcase = filelist[i]
        casepath = allCasepath + testcase
        runFirstresult = getCasesResults.runcase(
            casepath, casesheet, caseresult)  ####手动配置case生成case结果及对比
        writeExcelresult.writeResult(runFirstresult, casepath, caseresult)
        runFirstnullresult = getAutoCasesResults.createcase(
            casepath, Autocasesheet, Autocaseresult,
            Speparamlist)  ####自动生成case结果及对比
        writeExcelresult.writeResult(runFirstnullresult, casepath,
                                     Autocaseresult)
        runresult = getParam.createtypecase(casepath, Autocasesheet,
                                            Autotyperesult, typelist)
        Execution.Executionmode2(runresult, casepath, Autotyperesult)
示例#5
0
def Executionmode(runresult,casepath,resultname):
	bk = xlrd.open_workbook(casepath, formatting_info=True)  # 打开excel文件
	if resultname in bk.sheet_names():
		ch = bk.sheet_by_name(resultname)
		nrows = ch.nrows
		ncols = ch.ncols
		# print runresult
		resultlist=runresult[1::2]
		for m in range(1, nrows):
			AC_result = resultlist[m - 1]
			# print AC_result
			EX_result = ch.cell_value(m, ncols - 1)
			eachcase = ch.cell_value(m, ncols - 2)
			finalresult = acex(AC_result, EX_result)
			if finalresult == False:
				writeLog.errorlog('FAIL:wrong datas case is number:case%s' % m, eachcase)
	else:
		print runresult
		writeExcelresult.writeResult(runresult,casepath,resultname)
示例#6
0
def runcase(casepath, sheetname, resultname):
    bk = xlrd.open_workbook(casepath)  # 打开excel文件
    httpString = bk.sheet_by_name('Sheet1').cell_value(0, 0)  # 接口url在表1里
    sh = bk.sheet_by_name(sheetname)  # 测试数据在表2里
    mrows = sh.nrows
    mcols = sh.ncols
    runFirstresult = []
    a = FileOperation.FileExsit(os.getcwd() + r'/log/failresult.html')
    if a == True:
        FileOperation.DelFile(os.getcwd() + r'/log/failresult.html')
    try:  #拼接参数名与参数值
        for j in range(1, mrows):
            methods = sh.cell_value(j, 2)
            testcase = []
            for i in range(3, mcols):
                x = sh.cell_value(0, i)  # 参数名,获取单元格的数据类型
                y = sh.cell_value(j, i)  # 参数值
                xtype = sh.cell(0, i).ctype
                ytype = sh.cell(j, i).ctype
                ###################ctype :  0 empty,1 string, 2 number, 3 date, 4 boolean, 5 error
                if (xtype == 2):
                    x = str(int(x))
                if (ytype == 2) or (ytype == 4):
                    y = str(int(y))
                    y = str(y)
                if x.find(' ') != -1 or y.find(' ') != -1:
                    x = x.replace(' ', '+')
                    y = y.replace(' ', '+')
                if ytype == 4 and y == '1':
                    y = 'True'
                elif ytype == 4 and y == '0':
                    y = 'False'
                if methods == 'GET':
                    element2 = x + '=' + y
                else:
                    element2 = '"' + x + '":"' + y + '"'
                testcase.append(element2)
            # print testcase
            AC_result = Requesttype.Requesttype(methods, testcase, httpString)
            eachcase = Requesttype.Requestcase(methods, testcase, httpString)
            # print AC_result
            runFirstresult.append(eachcase)
            runFirstresult.append(AC_result)
        # print runFirstresult
        if resultname in bk.sheet_names():
            ch = bk.sheet_by_name(resultname)
            nrows = ch.nrows
            ncols = ch.ncols
            resultlist = runFirstresult[1::2]
            # print resultlist
            for m in range(1, nrows):
                AC_result = resultlist[m - 1]
                EX_result = ch.cell_value(m, ncols - 1)
                finalresult = ACEXcompare.acex(AC_result, EX_result)
                if finalresult == False:
                    writeLog.errorlog(
                        'FAIL:wrong datas case is number:case%s' % m, eachcase)
        else:
            return runFirstresult
            writeExcelresult.writeResult(runFirstnullresult, resultpath,
                                         defaultname)

    except Exception, e:
        print e
示例#7
0
            runFirstresult.append(eachcase)
            runFirstresult.append(AC_result)
        # print runFirstresult
        if resultname in bk.sheet_names():
            ch = bk.sheet_by_name(resultname)
            nrows = ch.nrows
            ncols = ch.ncols
            resultlist = runFirstresult[1::2]
            # print resultlist
            for m in range(1, nrows):
                AC_result = resultlist[m - 1]
                EX_result = ch.cell_value(m, ncols - 1)
                finalresult = ACEXcompare.acex(AC_result, EX_result)
                if finalresult == False:
                    writeLog.errorlog(
                        'FAIL:wrong datas case is number:case%s' % m, eachcase)
        else:
            return runFirstresult
            writeExcelresult.writeResult(runFirstnullresult, resultpath,
                                         defaultname)

    except Exception, e:
        print e


#########################################################################
if __name__ == '__main__':
    runFirstresult = runcase(os.getcwd() + r'/mycase/demo.xls', 'Sheet2',
                             'CaRe')
    writeExcelresult.writeResult(runFirstresult,
                                 os.getcwd() + r'/mycase/demo.xls', 'CaRe')
示例#8
0
def createcase(casepath, defaultname, resultname, Speparamlist):
    bk = xlrd.open_workbook(casepath, formatting_info=True)  # 打开excel文件
    httpString = bk.sheet_by_name('Sheet1').cell_value(0, 0)  # 接口url在表1里
    sh = bk.sheet_by_name(defaultname)
    runFirstnullresult = []
    methods = sh.cell_value(1, 1)
    a = FileOperation.FileExsit(os.getcwd() + r'/log/failresult.html')
    if a == True:
        FileOperation.DelFile(os.getcwd() + r'/log/failresult.html')
    try:

        list1 = getvalue.getdvalue(casepath, defaultname, methods)
        if methods == 'GET':
            mypermission = permission1
        else:
            mypermission = permission2
        for i in range(len(list1) - 1, len(list1)):  ###大于等于列表长度-1参数
            nulllist = []
            iter = itertools.combinations(list1, i)  ###i表示取列表中的n个参数进行组合
            nulllist.append(list(iter))  ######iter是一个循环器,所以它的值只能用1次,需要把值存到变量里
        # print nulllist
        for j in range(0, len(nulllist[0])):  ####生成列表个数
            parameter1 = mypermission
            parameter2 = list(nulllist[0][j])
            testcase = parameter1 + parameter2
            # print testcase
            AC_result = Requesttype.Requesttype(methods, testcase, httpString)
            eachcase = Requesttype.Requestcase(methods, testcase, httpString)
            # print eachcase
            # print EX_result
            runFirstnullresult.append(eachcase)
            runFirstnullresult.append(AC_result)
        for i in range(0, len(list1)):
            for y in Speparamlist:
                parameter1 = getvalue.getdvalue(casepath, defaultname, methods)
                x = sh.cell_value(i + 4, 0)
                if methods == 'GET':
                    element2 = x + '=' + y
                else:
                    element2 = '"' + x + '":"' + y + '"'
                parameter1.pop(i)
                # print list1
                parameter1.append(element2)
                # print parameter1
                parameter = mypermission
                testcase = parameter + parameter1
                AC_result = Requesttype.Requesttype(methods, testcase,
                                                    httpString)
                eachcase = Requesttype.Requestcase(methods, testcase,
                                                   httpString)
                runFirstnullresult.append(eachcase)
                runFirstnullresult.append(AC_result)
        # print runFirstnullresult
        if resultname in bk.sheet_names():
            ch = bk.sheet_by_name(resultname)
            nrows = ch.nrows
            ncols = ch.ncols
            resultlist = runFirstnullresult[1::2]
            # print resultlist
            for m in range(1, nrows):
                AC_result = resultlist[m - 1]
                EX_result = ch.cell_value(m, ncols - 1)
                finalresult = ACEXcompare.acex(AC_result, EX_result)
                if finalresult == False:
                    writeLog.errorlog(
                        'FAIL:wrong datas case is number:case%s' % m, eachcase)
        else:
            return runFirstnullresult
            writeExcelresult.writeResult(runFirstnullresult, resultpath,
                                         defaultname)

    except Exception, e:
        print e