深圳做服装设计网站的公司贷款平台代理怎么加入
2026/4/18 11:53:38 网站建设 项目流程
深圳做服装设计网站的公司,贷款平台代理怎么加入,北京建设网站设计,怎么制作网页设计#x1f345; 点击文末小卡片 #xff0c;免费获取软件测试全套资料#xff0c;资料在手#xff0c;涨薪更快 接口自动化测试框架目的 测试工程师应用自动化测试框架的目的#xff1a;增强测试脚本的可维护性、易用性(降低公司自动化培训成本#xff0c;让公司的测试工程…点击文末小卡片免费获取软件测试全套资料资料在手涨薪更快接口自动化测试框架目的测试工程师应用自动化测试框架的目的增强测试脚本的可维护性、易用性(降低公司自动化培训成本让公司的测试工程师都可以开展自动化测试)。自动化测试框架根据思想理念和深度不同渐进式的分为以下几种:线性脚本框架模块化思想模块化测试脚本框架库思想测试库框架。数据驱动思想数据驱动测试框架关键字驱动思想关键字驱动或表驱动的测试框架上述思想融合完成企业实际自动化混合测试自动化框架编写线性测试脚本实战接口用例excel;步骤1、新建项目名API_TEST_FRAME在项目的下面新建不同层级如下图步骤2、根据接口文档的层级在项目中的testcase层下新建层级如下图步骤3、在begin_dev下新建test_get_access_token_api.py文件并编写代码编写代码# encoding: utf-8 # author: Jeffrey # file: test_get_access_token_api.py # time: 2022/7/24 18:08 # desc: 导入模块顺序内置模块、第三方模块、自定义模块 import unittest import requests import jsonpath class TestGetAccessTokenApi(unittest.TestCase): def setUp(self) - None: self.session requests.session() def tearDown(self) - None: self.session.close() def test_case_01(self): [api_case_01] 测试获取access_token能否正常调用 url_params {grant_type:client_credential, appid:wxf14419077f707856, secret:92a113bd4b5ffdc72144740dc7123c99} response self.session.get(urlhttps://api.weixin.qq.com/cgi-bin/token, params url_params) # 获取响应json中的access_token的值 actual_result jsonpath.jsonpath(response.json(), $.access_token) print(actual_result) self.assertTrue(actual_result, api_case_01 执行失败) #非空非0 都返回True为真 def test_case_02(self): [api_case_02] 测试获取access_token接口在appid错误时能否正常处理错误 url_params {grant_type:client_credential, appid:wxf14419077f707, secret:92a113bd4b5ffdc72144740dc7123c99} response self.session.get(urlhttps://api.weixin.qq.com/cgi-bin/token, params url_params) # 获取响应json中的errcode的值,因为jsonpath返回的是列表故加上下标0 actual_result jsonpath.jsonpath(response.json(), $.errcode)[0] print(actual_result) self.assertEqual(actual_result,40013, api_case_02 执行失败) if __name__ __main__: unittest.main(verbosity2)执行查看结果步骤4、按照开发文档中的用户标签管理新建test_create_user_tag_api.py文件编写代码# encoding: utf-8 # author: Jeffrey # file: test_create_user_tag_api.py # time: 2022/7/24 19:02 # desc: import unittest import requests import jsonpath import json class TestCreateUserTagApi(unittest.TestCase): def setUp(self) - None: self.session requests.session() def tearDown(self) - None: self.session.close() def test_case_01(self): [api_case_03] 测试正常进行创建标签接口调用 url_params {grant_type:client_credential, appid:wxf14419077f707856, secret:92a113bd4b5ffdc72144740dc7123c99} response self.session.get(urlhttps://api.weixin.qq.com/cgi-bin/token, params url_params) # 获取响应json中的access_token的值 token_value jsonpath.jsonpath(response.json(), $.access_token)[0] tag_url_params {access_token:token_value} tag_boby { tag: { name:深圳人2 } } # 解决中文乱码问题;模拟post请求时携带json 数据包含中文发送给服务器会转码 # 方式一json.dumps() tag_str json.dumps(tag_boby, ensure_asciiFalse) response self.session.post(urlhttps://api.weixin.qq.com/cgi-bin/tags/create, params tag_url_params, datatag_str.encode(utf-8)) print(response.json()) # # 方式二修改requests中的models.py中的源码,修改完后 # response self.session.post(urlhttps://api.weixin.qq.com/cgi-bin/tags/create, # paramstag_url_params, # jsontag_boby) # print(response.json()) # 获取响应json的tag的name值因为jsonpath返回的是列表故加上下标0 actual_result jsonpath.jsonpath(response.json(), $.tag.name)[0] self.assertEqual(actual_result,深圳人2, api_case_03 执行失败) if __name__ __main__: unittest.main(verbosity2)Requests模拟post请求时如何处理携带json 数据包含中文发送给服务器会转码的问题?方式一如下图方式二如下图执行结果继续新建test_update_user_tag_api.py文件和test_delete_user_tag_api.py文件自己拓展步骤5、把用例整合一起执行在runner文件下的run_api_tests.py中编写代码编写代码# encoding: utf-8 # author: Jeffrey # file: run_api_tests.py # time: 2022/7/24 17:52 # desc: import os import unittest # 获取当前路径 current_path os.path.dirname(os.path.abspath(__file__)) # 测试用例路径 case_path os.path.join(current_path, ../testcases) discover_obj unittest.defaultTestLoader.discover(start_dircase_path, patterntest*.py) all_case_suite unittest.TestSuite() # 把discover对象发现的用例加载到测试套件中 all_case_suite.addTest(discover_obj) unittest.main(defaultTestall_case_suite, verbosity2)查看执行结果步骤6、生成测试报告把HTMLTestReportCN.py文件放到common文件夹中并在run_api_tests.py文件中调整代码编写代码# encoding: utf-8 # author: Jeffrey # file: run_api_tests.py # time: 2022/7/24 17:52 # desc: import os import unittest from common import HTMLTestReportCN # 获取当前路径 current_path os.path.dirname(os.path.abspath(__file__)) # 测试用例路径 case_path os.path.join(current_path, ../testcases) discover_obj unittest.defaultTestLoader.discover(start_dircase_path, patterntest*.py) all_case_suite unittest.TestSuite() # 把discover对象发现的用例加载到测试套件中 all_case_suite.addTest(discover_obj) # unittest.main(defaultTestall_case_suite, verbosity2) report_path os.path.join(current_path, ../reports/result.html) html_file_obj open(report_path, wb) html_runner HTMLTestReportCN.HTMLTestRunner(streamhtml_file_obj, title接口接口自动化测试, testerYOU, description学习接口框架) html_runner.run(all_case_suite)执行后查看报告最后感谢每一个认真阅读我文章的人礼尚往来总是要有的虽然不是什么很值钱的东西如果你用得到的话可以直接拿走这些资料对于做【软件测试】的朋友来说应该是最全面最完整的备战仓库这个仓库也陪伴我走过了最艰难的路程希望也能帮助到你凡事要趁早特别是技术行业一定要提升技术功底。

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询