# tp商城-接口自动化-案例 **Repository Path**: maidang_study/tp-shopping-mall-interface-automation-case ## Basic Information - **Project Name**: tp商城-接口自动化-案例 - **Description**: tpshop商城项目的接口测试案例,提供给有兴趣的同学参考学习。 - **Primary Language**: Python - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 9 - **Forks**: 2 - **Created**: 2023-08-04 - **Last Updated**: 2025-07-06 ## Categories & Tags **Categories**: Uncategorized **Tags**: Python, pytest, Requests ## README # tpshop商城-接口自动化-案例 #### 介绍 - tpshop商城项目的接口测试案例,主要用到了添加商品和删除商品两个接口来做演示。 - 使用了python+requests+pytest+数据驱动(参数化)+测试报告(allure)来实现的。 #### 目录架构 ![输入图片说明](Snipaste_2023-08-04_21-25-02.png) - api - 定义封装被测系统的接口 - script - 定于测试用例脚本 - data - 存放测试数据文件 - report - 存放生成的测试报告 - common - 存放通用工具类 - config.py - 定义项目的配置信息 - pytest.ini - pytest配置文件 #### 相关软件安装教程 1. python(3.1.2) 下载地址:https://www.python.org/downloads/ 2. pycharm(社区版) 下载地址:https://www.jetbrains.com/pycharm/download/ 3. pytest(7.4.0) 下载方法:在pycharm安装或使用pip命令安装,安装命令:pip install pytest 4. requests(2.31.0) 下载方法:在pycharm安装或使用pip命令安装,安装命令:pip install requests 5. allure-pytest(2.13.2) 下载方法:在pycharm安装或使用pip命令安装,安装命令:pip install allure-pytest 6. allure(2.18.1) 下载地址:https://github.com/allure-framework/allure2/releases 注:allure下载解压到没有中文目录中,然后添加到环境变量中,添加后在命令行窗口输入 allure --version 命令来查看版本确认是否安装成功! #### 使用说明 1. 前提:以上软件安装完成,接口脚本编写完成且调试通过后 2. 在pycharm的Terminal窗口中输入:pytest 命令执行测试脚本 3. 执行脚本后在输入:allure serve report 命令生成测试报告并以网页形式打开(report是目录名称,根据需求可修改) 测试报告示例: ![输入图片说明](Snipaste_2023-08-04_21-37-38.png) ![输入图片说明](Snipaste_2023-08-04_21-38-02.png) ![输入图片说明](Snipaste_2023-08-04_21-38-29.png) python接口自动化脚本(附带postman)运行效果视频:https://b23.tv/6LMz7Vy #### 参与贡献 1. Fork 本仓库 2. 新建 Feat_xxx 分支 3. 提交代码 4. 新建 Pull Request #### 特技 1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md 2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com) 3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目 4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目 5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) 6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)