zoukankan      html  css  js  c++  java
  • 【自动化测试】如何修改rf项目下的报告位置-针对中文乱码问题不完全修复

      因为修改了报告的位置,从而导致了我们点开ride的log或者report会找不到指定文件位置。通过代码分析,初步定位是使用cmd读取的时候,针对中文转义出现了问题,对ride的源码也没有完全读透。所以只能给出感觉比较可以的解决方案:将log仍旧放回我们的临时文件位置,将report放在我们的项目位置下面,这样我们调试某些问题,还是可以通过点击log来查看问题。而且report和log不受其位置影响,仍旧可以相互点击跳跃。由于改动代码会导致制表符报错的问题,不建议大家直接在testrunner.py改动,所以提供下载地址:https://pan.baidu.com/s/1wKJ-chrghO2rangG42qtGQ 提取码: xgsi 复制这段内容后打开百度网盘手机App,操作更方便哦 

      

       改动代码如下:

        紫色字体代码是还原,红色字体代码是增加

       def _create_standard_args(
                self, command, profile, pythonpath, console_width, names_to_run):
            standard_args = []
            standard_args.extend(profile.get_custom_args())
            self._add_url_by_user(command, standard_args)
            self._add_tmp_outputdir_if_not_given_by_user(command, standard_args)                
            self._add_pythonpath_if_in_settings_and_not_given_by_user(
                command, standard_args, pythonpath)            
            # Have to use short options, because of long option was changed in
            # RF 2.8 -> 2.9, and we don't necessarily know the installed version.
            standard_args.extend(["-C", "off"])  # --consolecolor
            
            standard_args.extend(["-W", console_width])  # --consolewidth
            
            for suite, test in names_to_run:
                standard_args += ['--suite', suite, '--test', test]
            return standard_args
    
        def _add_tmp_outputdir_if_not_given_by_user(self, command, standard_args):
            if "--outputdir" not in command and "-d" not in command:
                standard_args.extend(["--outputdir", self._output_dir])
                
    
        def _add_url_by_user(self,command,standard_args):
                if "--report" not in command and "-d" not in command:
                    suiteurl = os.path.abspath(self._project.suite.source)
                    repurl = os.path.join(suiteurl,"report","自动化测试报告")
                    standard_args.extend(["--report",repurl])

      最后结果如下

     

         

       重新优化了一下源码,可能我们 需要原来的报告,但是我们运行了导致报告被替换。根据斟酌,选择按天来保存报告,这样我们至少能保留一天一份报告。

     

        def _add_url_by_user(self,command,standard_args):
                if "--report" not in command and "-d" not in command:
                    suiteurl = os.path.abspath(self._project.suite.source)
                    ti = time.localtime()
                    reportime = "".join([str(ti[0]),str(ti[1]),str(ti[2])])
                    repurl = os.path.join(suiteurl,"report"+reportime,"自动化测试报告")
                    standard_args.extend(["--report",repurl])

     

  • 相关阅读:
    Powershell分支条件
    Powershell基础
    初识PowerShell
    设计模式--策略模式
    设计模式--简单工程模式
    StandardWrapper
    Tomcat的安全性
    算法效率 简单的增长率 参照

    排序算法之 归并排序
  • 原文地址:https://www.cnblogs.com/mumushizhige/p/14048945.html
Copyright © 2011-2022 走看看