# HS19_cjw **Repository Path**: caijianwei01/hs19_cjw ## Basic Information - **Project Name**: HS19_cjw - **Description**: 框架测试Demo - **Primary Language**: Python - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-06-17 - **Last Updated**: 2022-09-21 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 测开19期作业 *** **创建虚拟环境(默认使用系统的版本,也可以指定版本):** 1. 进入项目根目录下,创建虚拟环境执行命令:virtualenv venv(虚拟环境名称) 2. 进入目录:cd venv/Scripts, 激活虚拟环境:activate.bat 文件路径最前面显示(venv),那么虚拟环境就激活成功了 3. 更新pip: python.exe -m pip install --upgrade pip 4. 切换到根目录:cd ../../, 安装所有需要的包:pip install -r requirements.txt **pip常用命令使用:** * 导出虚拟环境安装包:pip freeze > requirements.txt * 在其它虚拟环境安装requirements.txt文件中的包: pip install -r requirements.txt *** ## 第一次作业:pytest_task1 **作业要求:** 1. 补全计算器(加法 除法)的测试用例 2. 使用参数化完成测试用例的自动生成 3. 在调用测试方法之前打印【开始计算】,在调用测试方法之后打印【计算结束】 * 注意: * 使用等价类,边界值,因果图等设计测试用例 * 测试用例中添加断言,验证结果 * 灵活使用 setup(), teardown(), setup_class(), teardown_class() **使用新的第三方库:** - pytest - pyyaml 用例设计图,加法和除法区别在于除数不能为零: ![Image text](https://gitee.com/caijianwei01/hs19_cjw/raw/master/images/Snipaste_2021-06-19_04-13-24.jpg) *** ## 第二次作业:pytest_task2 **作业要求:** - 1.改造 计算器 测试用例,使用 fixture 函数获取计算器的实例 - 2.计算之前打印开始计算,计算之后打印结束计算 - 3.添加用例日志,并将日志保存到日志文件目录下 - 4.生成测试报告,展示测试用例的标题,用例步骤,与测试日志,截图附到课程贴下 **使用新的的插件和第三方库:** - allure-pytest - pytest-rerunfailures - pytest-xdist - concurrent-log-handler pytest-xdist 多进程写日志到文件,使用第三方包 concurrent-log-handler ```bash pip install concurrent-log-handler ``` **存在的问题:** - 多进程并发执行时,类级别的fixture也会重复执行 - 控制台输出的日志只有简化的 ![Image text](https://gitee.com/caijianwei01/hs19_cjw/raw/master/images/Snipaste_2021-06-21_14-32-48.png) *** ## 第三、四次作业:web_wework **各个浏览器驱动下载地址:** - chrome:https://npm.taobao.org/mirrors/chromedriver/ - firefox:https://npm.taobao.org/mirrors/geckodriver/ - Opera:https://github.com/operasoftware/operachromiumdriver/releases - edge:https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/#downloads 使用的驱动版本:chrome(91.0.4472.101)、firefox(0.29.1)、edge(91.0.864.54) **复用浏览器启动命令:** - windows ```bash chrome --remote-debugging-port=9222 ``` - mac/linux ```bash Google/Chrome --remote-debugging-port=9222 ``` **使用新的第三方库:** - selenium - Faker **功能时序图:** ![Image text](https://gitee.com/caijianwei01/hs19_cjw/raw/master/images/Snipaste_2021-06-28_01-01-36.jpg) *** ## 第五次作业:app_wework **作业内容:** 使用 Appium 实现自动化添加联系人 备注:没有使用po的情况下,定位使用参数化稍微有点复杂,麻烦 **使用新的第三方库:** - Appium-Python-Client - PyHamcrest ## 第六次作业:app_wework_po **作业内容:** - 实现添加联系人功能的 PO 封装 - 实现删除联系人功能的 PO 封装 ## 第七次作业:mock_task **作业内容:** - 实现 MapLocal 修改雪球行情页的股票名称改为自己的名字 - 实现 Rewrite 实现股票颜色变换的的边界值测试 通过mitmproxy实现 **使用的第三方库:** - mitmproxy ![Image text](https://gitee.com/caijianwei01/hs19_cjw/raw/master/images/Snipaste_2021-07-11_20-25-34.jpg) ## 第八次作业:server_task **使用的第三方库:** - requests - jsonpath **用例编写思考模型** ![Image text](https://gitee.com/caijianwei01/hs19_cjw/raw/master/images/Snipaste_2021-07-19_22-59-12.jpg) **根据思考模型进行接口用例设计** - 基本功能流程测试 ![Image text](https://gitee.com/caijianwei01/hs19_cjw/raw/master/images/Snipaste_2021-07-19_23-02-10.jpg) - 基于输入域的测试用例-边界值 ![Image text](https://gitee.com/caijianwei01/hs19_cjw/raw/master/images/Snipaste_2021-07-19_23-04-32.jpg) - 基于输入域的测试用例-其它校验 ![Image text](https://gitee.com/caijianwei01/hs19_cjw/raw/master/images/Snipaste_2021-07-19_23-06-39.jpg) - 基于线程安全的测试 ![Image text](https://gitee.com/caijianwei01/hs19_cjw/raw/master/images/Snipaste_2021-07-19_23-07-46.jpg) **备注** 1. 接口用例的数据需要独立,而且需要唯一,方便并发执行 2. 暂时只实现了通讯录管理三个接口的基本增删改查的冒烟测试用例 3. 后续会挑一个接口进行完善