chengc преди 2 дни
родител
ревизия
5cf95b5dfb
променени са 7 файла, в които са добавени 100 реда и са изтрити 0 реда
  1. 2 0
      .gitignore
  2. 98 0
      README.md
  3. BIN
      images/1.git-clone.png
  4. BIN
      images/2.import-collection.png
  5. BIN
      images/3.import-enviroment.png
  6. BIN
      images/4.apply-enviroment-2-collection.png
  7. BIN
      images/5.export-collection.png

+ 2 - 0
.gitignore

@@ -0,0 +1,2 @@
+# Postman 环境变量文件不要上传
+environments/

+ 98 - 0
README.md

@@ -0,0 +1,98 @@
+# T-ERP AutoTest
+
+T系列ERP自动化测试 Postman Collection 仓库,用于 Jenkins 集成。
+
+## 项目结构
+
+```
+├── collections/
+│   └── t-erp-auto-test.json    # Postman 集合文件
+├── environments/
+│   └── api-tests-env.json      # Postman 环境变量文件
+├── images/                     # 操作截图
+├── .gitignore                  # Git 忽略规则
+└── README.md                   # 项目说明文档
+```
+
+## Git 配置
+
+首次使用需配置 Git 身份信息,提交记录会关联到你的账号:
+
+```bash
+git config --global user.name "你的姓名"
+git config --global user.email "你的邮箱"
+```
+
+> 如果只想在当前仓库生效,去掉 `--global` 即可。
+
+## 快速上手
+
+### 1. 克隆仓库
+
+```bash
+git clone http://122.112.209.52/Testing/AutoTest.git
+cd AutoTest
+```
+
+![克隆仓库](images/1.git-clone.png)
+
+### 2. 导入 Collection
+
+打开 Postman → 点击左上角 **Import** → 选择 `collections/t-erp-auto-test.json`。
+
+![导入集合](images/2.import-collection.png)
+
+### 3. 导入环境变量
+
+同样方式导入 `environments/api-tests-env.json`。
+
+![导入环境变量](images/3.import-enviroment.png)
+
+### 4. 应用环境变量到集合
+
+在 Postman 右上角环境变量下拉框中选择 **api-tests-env**,使集合使用该环境配置。
+
+![应用环境](images/4.apply-enviroment-2-collection.png)
+
+### 5. 导出并提交
+
+修改完成后,右键集合 → **Export** → 选择 **Collection v2.1** 格式(默认)→ 导出为 `t-erp-auto-test.json`,覆盖 `collections/t-erp-auto-test.json`,然后提交到 Git:
+
+```bash
+git add collections/t-erp-auto-test.json
+git commit -m "update collection"
+git push
+```
+
+![导出集合](images/5.export-collection.png)
+
+## 用例维护
+
+- Newman 每次运行只执行一个 Collection 文件,因此所有用例统一维护在 `t-erp-auto-test` 集合中。
+- 如需维护个人测试用例、又担心误改他人用例,可在 `t-erp-auto-test` 集合下创建**自己的子文件夹**,将个人用例放入其中即可,互不影响。
+- 自动化测试的执行顺序为 `t-erp-auto-test` 集合中**从上到下依次执行**全部用例。
+
+## 测试环境
+
+当前 `environments/api-tests-env.json` 配置的 API 连接信息:
+
+| 项目 | 值 |
+| ---- | --- |
+| 主机 | `192.168.10.237` |
+| 账套 | `TAPI` |
+| 用户 | `API` |
+| 密码 | `123` |
+
+> TAPI 账套设置了 SQL Server 代理作业,**每天凌晨 0 点自动还原为空账套**。如需调整请联系陈工(<chengc@amtxts.com>)。
+
+## 自动执行与报告
+
+Jenkins 每天凌晨 2 点多自动执行 `t-erp-auto-test` 集合的全部用例,测试报告可在线查看:
+
+👉 [https://attnserver.com/Updates/AutoTest/index.html](https://attnserver.com/Updates/AutoTest/index.html)
+
+## 注意事项
+
+- **不要覆盖或上传 `environments/` 目录下的文件**。环境变量文件仅供本地导入使用,不应提交到仓库。
+- 需要新增环境变量时,以 **集合变量(Collection Variable)** 形式添加,**不要创建全局变量(Global Variable)**。
+- 集合变量应在postman脚本中动态创建,保证每次运行时的变量状态干净、可复现。

BIN
images/1.git-clone.png


BIN
images/2.import-collection.png


BIN
images/3.import-enviroment.png


BIN
images/4.apply-enviroment-2-collection.png


BIN
images/5.export-collection.png