def __init__(self, log_path):
     """
     :param log_path: 日志文件的路径
     """
     self.file_name = getPorjectPath() + log_path
     self.logger = logging.getLogger()
     # 设置日志等级
     self.logger.setLevel(logging.INFO)
     # 设置日志的输出格式
     self.formatter = logging.Formatter(
         '%(levelname)s - %(asctime)s - %(message)s')
def run(cases=" "):
    """运行case中所有用例"""

    clearLogAndReport()
    print("------------开始执行测试------------")
    cmd = "pytest " + getPorjectPath(
    ) + "/case/" + cases + " --alluredir " + getPorjectPath(
    ) + "/result/report"
    print(os.system(cmd))
    s = input("请选择要启用的服务:1:启动失败用例重跑;\t2:启动测试报告;")
    if s == "1":
        print("启动失败用例重跑")
        cmd = "pytest --lf " + getPorjectPath(
        ) + "/case/" + cases + " --alluredir " + getPorjectPath(
        ) + "/result/report"
        print(os.system(cmd))
        s = input("是否启动测试报告:y/n")
    if s == "2" or s == "y":
        print("-------------启动测试报告--------------")
        startReport = "allure serve " + getPorjectPath() + "/result/report"
        print(os.system(startReport))
Exemple #3
0
 def read_Ini():
     """读取INI文件"""
     Ini_Path = getPorjectPath() + r"\resources\conf\config.ini"
     config = configparser.ConfigParser()
     config.read(Ini_Path)
     return config
def clearLogAndReport():
    print("----------清空上次测试结果----------")
    path = getPorjectPath() + "/result"
    ClearTestResult(path)
    time.sleep(2)
    print("----------测试结果清空成功----------")
 def __init__(self, csv_path):
     self.csv_path = getPorjectPath() + csv_path
 def __init__(self, yaml_path):
     self.yaml_path = getPorjectPath() + yaml_path