• 20191011-构建我们公司自己的自动化接口测试框架-Util的getTestSuite模块


    getTestSuite主要是用于在testData里面获取测试集以及对应的测试数据,包括2个主要的方法,一个是获取测试集,一个是获取测试集里面要执行的测试用例

    获取测试集方法:

    from Util.ParseExcel import *
    from ProVar.ProjConfigVar import *
    from Util.Log import *
    def get_test_case_sheet_names(test_data_excel_path):
        # 读取测试集里面要测试的sheet
        # 读取行号和需要执行的测试用例sheet名字以及执行模式
        test_cases_wb = Excel(test_data_excel_path)
        test_cases_wb.set_sheet_by_index(1)
        test_case_to_be_run_sheet_names = []
        for row in test_cases_wb.get_rows_values():
            # 如果测试用例是否执行=是,记录当前用例到测试集里面
            if row[Test_Suit_is_executed_col_no] is not None and row[Test_Suit_is_executed_col_no].lower() == "y":
                #1个序号和1个测试用例sheet名称组成一个元组
                #多个元组放入到列表中,组成一个测试用例sheet的集合列表
                test_case_to_be_run_sheet_names.append((row[Test_Suit_map_serials_col_no],row[Test_Suit_test_step_sheet_name_col_no],row[Test_Suit_is_executed_mode_col_no]))
        # 返回测试集
        return test_case_to_be_run_sheet_names

    获取测试用例方法:获取主要的测试数据,包括需要,请求方法,请求url,请求头,请求body,断言表,断言词,变量提取表达式,请求名字等,获取到这些数据后需要对这些数据进行处理,参加testdatahandler

    def test_cases_from_test_data_sheet(test_data_excel_path,test_data_sheet_name):
        """获取具体测试用例的数据"""
        test_cases_wb = Excel(test_data_excel_path)
        test_cases_wb.set_sheet_by_name(test_data_sheet_name)
        # 读取所有的接口测试用例
        test_cases = []
        for row in test_cases_wb.get_rows_values():
            if row[Test_Case_isExecute_col_no] is not None and row[Test_Case_isExecute_col_no].lower() == "y":
                # test_case 匹配api_request(method, baseurl, header, auth, body)5个参数
                # test_case = [序号,请求方法,请求url,请求头,授权信息,请求body,断言结果,提取正则表达式]
                test_case = row[Test_Case_serials_col_no], row[Test_Case_action_col_no], row[Test_Case_baseurl_col_no],row[Test_Case_header_col_no],row[Test_Case_auth_col_no],row[Test_Case_body_col_no],
                row[Test_Case_assert_content_col_no],row[Test_Case_var_get_col_no],row[Test_Case_assert_word_col_no],row[Test_Case_name_col_no]
                test_cases.append(test_case)
        # print(test_cases)
        # 返回测试关键字
        return test_cases
  • 相关阅读:
    python 基础第二篇
    python 基础第五篇
    python 基础第四篇
    购物小编程(完整编码)
    计算机 python概论
    str 相关操作
    python 基础第三篇
    Nginx 配置多站点vhost
    h5页面宽度设置7.5rem
    js 倒计时,转义
  • 原文地址:https://www.cnblogs.com/hyj691001/p/11654819.html
Copyright © 2020-2023  润新知