zoukankan      html  css  js  c++  java
  • httprunner3 log放到allure中显示

    httprunner3的log本身是不能在allure上展示的

    可以通过改写Libsite-packageshttprunner unner.py文件中的test_start方法实现报告存放allure中展示

    添加一行

    allure.attach.file(self.__log_path, name='log', attachment_type=allure.attachment_type.TEXT)

    改写代码如下:

     def test_start(self, param: Dict = None) -> "HttpRunner":
            """main entrance, discovered by pytest"""
            self.__init_tests__()
            self.__project_meta = self.__project_meta or load_project_meta(
                self.__config.path
            )
            self.__case_id = self.__case_id or str(uuid.uuid4())
            # self.__log_path = self.__log_path or os.path.join(
            #     self.__project_meta.RootDir, "logs", f"{self.__case_id}.run.log"
            # )
            self.__log_path = os.path.join(self.__project_meta.RootDir, "logs", "{}.txt".format(time.time()))
            log_handler = logger.add(self.__log_path, level="DEBUG")
    
            # parse config name
            config_variables = self.__config.variables
            if param:
                config_variables.update(param)
            config_variables.update(self.__session_variables)
            self.__config.name = parse_data(
                self.__config.name, config_variables, self.__project_meta.functions
            )
    
            if USE_ALLURE:
                # update allure report meta
                allure.dynamic.title(self.__config.name)
                allure.dynamic.description(f"TestCase ID: {self.__case_id}")
    
            logger.info(
                f"Start to run testcase: {self.__config.name}, TestCase ID: {self.__case_id}"
            )
    
            try:
                return self.run_testcase(
                    TestCase(config=self.__config, teststeps=self.__teststeps)
                )
            finally:
                allure.attach.file(self.__log_path, name='log', attachment_type=allure.attachment_type.TEXT)
                logger.remove(log_handler)
                logger.info(f"generate testcase log: {self.__log_path}")
  • 相关阅读:
    C# 英语纠错 LanguageTool
    WPF TreeView 虚拟化-设置滚动到选中项
    C# 同步更新系统时间
    C# 重置IE安全等级
    C# IE环境
    C# IE环境
    WPF ObservableCollection 异步调用问题
    C# 以函数Action/Func/Task作为方法参数
    WPF Geometry 引用Path数据
    ResourceDictionary主题资源替换(一) :通过加载顺序来覆盖之前的主题资源
  • 原文地址:https://www.cnblogs.com/erchun/p/15233423.html
Copyright © 2011-2022 走看看