forked from DxvLwRYF/apiAutoTest
1 line
6.0 KiB
JSON
1 line
6.0 KiB
JSON
{"name": "get请求查询用户数据列表", "status": "failed", "statusDetails": {"message": "AssertionError: 断言失败 -|- 实际结果:{'msg': '无效token', 'status': 400} || 预期结果: {'msg': '获取管理员列表成功', 'status': 200}", "trace": "cls = <class 'tools.data_process.DataProcess'>\nresponse = {'data': None, 'meta': {'msg': '无效token', 'status': 400}}\nexpect_str = '{\"$.meta\":{\"msg\": \"获取管理员列表成功\", \"status\": 200}}'\n\n @classmethod\n def assert_result(cls, response: dict, expect_str: str):\n \"\"\" 预期结果实际结果断言方法\n :param response: 实际响应结果\n :param expect_str: 预期响应内容,从excel中读取\n return None\n \"\"\"\n # 后置sql变量转换\n expect_str = rep_expr(expect_str, DataProcess.response_dict)\n expect_dict = convert_json(expect_str)\n index = 0\n for k, v in expect_dict.items():\n # 获取需要断言的实际结果部分\n actual = extractor(response, k)\n index += 1\n logger.info(f'第{index}个断言,实际结果:{actual} | 预期结果:{v} \\n断言结果 {actual == v}')\n allure_step(f'第{index}个断言', f'实际结果:{actual} = 预期结果:{v}')\n try:\n> assert actual == v\nE AssertionError\n\ntools\\data_process.py:118: AssertionError\n\nDuring handling of the above exception, another exception occurred:\n\ncases = ['case_004', 'get请求查询用户数据列表', 'users', '', 'get', 'data', ...]\n\n def test_main(cases): # 不使用数据库功能\n # 发送请求\n response, expect, sql = BaseRequest.send_request(cases)\n # 断言操作\n> DataProcess.assert_result(response, expect)\n\ntest\\test_api.py:35: \n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\n\ncls = <class 'tools.data_process.DataProcess'>\nresponse = {'data': None, 'meta': {'msg': '无效token', 'status': 400}}\nexpect_str = '{\"$.meta\":{\"msg\": \"获取管理员列表成功\", \"status\": 200}}'\n\n @classmethod\n def assert_result(cls, response: dict, expect_str: str):\n \"\"\" 预期结果实际结果断言方法\n :param response: 实际响应结果\n :param expect_str: 预期响应内容,从excel中读取\n return None\n \"\"\"\n # 后置sql变量转换\n expect_str = rep_expr(expect_str, DataProcess.response_dict)\n expect_dict = convert_json(expect_str)\n index = 0\n for k, v in expect_dict.items():\n # 获取需要断言的实际结果部分\n actual = extractor(response, k)\n index += 1\n logger.info(f'第{index}个断言,实际结果:{actual} | 预期结果:{v} \\n断言结果 {actual == v}')\n allure_step(f'第{index}个断言', f'实际结果:{actual} = 预期结果:{v}')\n try:\n assert actual == v\n except AssertionError:\n> raise AssertionError(f'断言失败 -|- 实际结果:{actual} || 预期结果: {v}')\nE AssertionError: 断言失败 -|- 实际结果:{'msg': '无效token', 'status': 400} || 预期结果: {'msg': '获取管理员列表成功', 'status': 200}\n\ntools\\data_process.py:120: AssertionError"}, "steps": [{"name": "请求地址", "status": "passed", "attachments": [{"name": "请求地址", "source": "87f05bb9-f71b-4dee-8960-6287bd0ff7ce-attachment.txt", "type": "text/plain"}], "start": 1611727380199, "stop": 1611727380199}, {"name": "请求头", "status": "passed", "attachments": [{"name": "请求头", "source": "0c57e2cd-4e3b-445b-b1b1-b504f0040152-attachment.txt", "type": "text/plain"}], "start": 1611727380199, "stop": 1611727380200}, {"name": "请求参数", "status": "passed", "attachments": [{"name": "请求参数", "source": "749f8d76-2d15-46c8-9e52-b9a7fcbb1e65-attachment.txt", "type": "text/plain"}], "start": 1611727380201, "stop": 1611727380202}, {"name": "上传文件", "status": "passed", "attachments": [{"name": "上传文件", "source": "0d658724-c66f-4ee9-9c56-e41de951c9ec-attachment.txt", "type": "text/plain"}], "start": 1611727380202, "stop": 1611727380203}, {"name": "响应耗时(s)", "status": "passed", "attachments": [{"name": "响应耗时(s)", "source": "2225bd89-f8b2-4f84-8b87-8913046d556e-attachment.txt", "type": "text/plain"}], "start": 1611727380250, "stop": 1611727380250}, {"name": "响应内容", "status": "passed", "attachments": [{"name": "响应内容", "source": "a424b383-932d-4de1-a40c-6cc04899a621-attachment.txt", "type": "text/plain"}], "start": 1611727380250, "stop": 1611727380251}, {"name": "存储实际响应", "status": "passed", "attachments": [{"name": "存储实际响应", "source": "6714bd92-686d-4180-9325-331947d53878-attachment.txt", "type": "text/plain"}], "start": 1611727380252, "stop": 1611727380253}, {"name": "第1个断言", "status": "passed", "attachments": [{"name": "第1个断言", "source": "0d615070-4ea4-4516-b625-a72ec7c07fce-attachment.txt", "type": "text/plain"}], "start": 1611727380254, "stop": 1611727380255}], "attachments": [{"name": "stderr", "source": "8c2fcafb-5ca3-4bc9-9af4-e2e3092ef995-attachment.txt", "type": "text/plain"}], "parameters": [{"name": "cases", "value": "['case_004', 'get请求查询用户数据列表', 'users', '', 'get', 'data', '', '{\"pagenum\": 1, \"pagesize\": \"12\", \"msg\": &$.msg&}', '', '{\"$.meta\":{\"msg\": \"获取管理员列表成功\", \"status\": 200}}']"}], "start": 1611727380199, "stop": 1611727380256, "uuid": "fa2d3a2b-6911-4e7c-be05-296a484e4cf2", "historyId": "f9a3a528aa08d345b131e068670a2332", "testCaseId": "881516e7ef2e2aa5436f6a3c3e6a5bcb", "fullName": "test.test_api#test_main", "labels": [{"name": "parentSuite", "value": "test"}, {"name": "suite", "value": "test_api"}, {"name": "host", "value": "LAPTOP-FR8LEA9G"}, {"name": "thread", "value": "5708-MainThread"}, {"name": "framework", "value": "pytest"}, {"name": "language", "value": "cpython3"}, {"name": "package", "value": "test.test_api"}]} |