• 最近有个小程序定位问题的 bug,开发将地区转换成地区 id 存储的时候转换错误了
    如果手工验证的话需要点点点走遍全国去定位?

    写单元测试的话只需要测试一下转换函数就好了

  • https://gitee.com/zx660644/uitest
    落地了的 ui 自动化项目

  • import pytest
    
    
    @pytest.fixture()
    def delete_data():
        test_data = {}
        yield test_data
        print(f"清理数据:{test_data}")
    
    
    def test_a(delete_data):
        delete_data["case_id"] = 1
        assert True
    
  • 这。。。

  • 十周年快乐!

  • 不合适就分手,蛮好

  • import curlify
    @staticmethod
    def show_response(response):
        attach_text(f'以「{response.request.method}」方式请求「{response.url}」;'
                    f'返回状态码为「{response.status_code}」'
                    f'返回内容为「{response.text}」',
                    "接口请求")
        attach_text(curlify.to_curl(response.request), "cURL")
        attach_text(response.url, "url")
        attach_text(response.request.method, "请求方式")
        attach_text(response.status_code, "状态码")
        attach_text(response.text, "返回内容-text")
        attach_text(response.json(), "返回内容-json")
    

    把 attach_text 换成 logger.info

  • 使用

    driver.activate_app(app_name)
    

    来切换 app

  • 在执行完用例之后,解析 allure 生成的 json 文件

    def get_allure_result(self, path=f'{REPORT_PATH}/allure_results'):
        """
    
        :param path: 存放allure运行json结果的文件夹
        :return:
        """
        result_list = [i for i in os.listdir(path) if '-result.json' in i]
        allure_results = []
        allure_dict = {}
        for i in result_list:
            json_data = self.read_json(os.path.join(path, i))
            full_name = json_data.get("fullName")
            labels = '_'.join([i.get('value', '') for i in json_data.get("labels") if
                               i.get('name', '') in ['feature', 'story']]) + "_" + json_data.get("name")
            parameters = json_data.get("parameters", '') and '_'.join([i.get('value', '') for i in
                                                                       json_data.get("parameters", '')])
            statusDetails = json_data.get('statusDetails', '')
            statusDetails1 = {
                "message": "",
                "trace": ""
            }
            if statusDetails:
                try:
                    statusDetails1["message"] = statusDetails.get("message", "")
                    statusDetails1["trace"] = statusDetails.get("trace", "")
                except Exception:
                    pass
            data = {
                "fullName": full_name,
                "status": json_data.get("status"),
                "labels": labels,
                "duration": json_data.get("stop", 0) - json_data.get("start", 0),
                "parameters": parameters,
                "statusDetails": statusDetails1
            }
            if f'{full_name}_{parameters}' not in allure_dict:
                allure_dict[f'{full_name}_{parameters}'] = [data]
            else:
                allure_dict[f'{full_name}_{parameters}'].append(data)
        for v in allure_dict.values():
            if len(v) == 1:
                allure_results.append(v[0])
            else:
                for v1 in v:
                    if 'pass' in v1.get("status"):
                        allure_results.append(v1)
                        break
                else:
                    allure_results.append(v[0])
        return allure_results