1. 程式人生 > 實用技巧 >【自動化測試】如何修改rf專案下的報告位置-針對中文亂碼問題不完全修復

【自動化測試】如何修改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])

  最後結果如下