Loading [MathJax]/jax/output/CommonHTML/config.js
部署DeepSeek模型,进群交流最in玩法!
立即加群
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >『接口测试干货』| Newman+Postman接口自动化测试完整过程

『接口测试干货』| Newman+Postman接口自动化测试完整过程

原创
作者头像
虫无涯
发布于 2023-11-25 01:08:34
发布于 2023-11-25 01:08:34
1.3K01
代码可运行
举报
文章被收录于专栏:全栈测试技术全栈测试技术
运行总次数:1
代码可运行

1 Newman简介

  • NewmanPostman的一个扩展库(NodeJs库);
  • Newman+Postman可完成接口自动化测试工作;
  • Postman导出的JSON格式文件可通过Newman的命令行执行;
  • 因为Postman运行后只有概要结果,没有像其他自动化测试框架那么完美漂亮的测试报告样式,所以引入了Newman
  • Newman可快速完成集合的运行,构造自动化以及持续集成工作。

2 如何安装Newman?

2.1 安装NodeJs

  • 下载地址:NodeJs
  • 下载后直接双击运行即可node-v20.10.0-x64.msi
    在这里插入图片描述
    在这里插入图片描述

2.2 安装Newman

  • 直接命令行输入以下命令即可:
代码语言:python
代码运行次数:1
运行
AI代码解释
复制
npm install -g newman
代码语言:python
代码运行次数:0
运行
AI代码解释
复制
C:\Windows\System32>npm install -g newman
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.

added 118 packages, and audited 119 packages in 15s

9 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
npm notice
npm notice New major version of npm available! 7.19.1 -> 10.2.4
npm notice Changelog: https://github.com/npm/cli/releases/tag/v10.2.4
npm notice Run npm install -g npm@10.2.4 to update!
  • 注意安装时要以管理员身份打开,不然会报错:
代码语言:python
代码运行次数:0
运行
AI代码解释
复制
C:\Users\Administrator>npm install -g newman
npm ERR! code EPERM
npm ERR! syscall open
npm ERR! path C:\Program Files\nodejs\node_cache\_cacache\tmp\9c4058f4
npm ERR! errno EPERM
npm ERR! FetchError: Invalid response body while trying to fetch https://registry.npmjs.org/newman: EPERM: operation not permitted, open 'C:\Program Files\nodejs\node_cache\_cacache\tmp\9c4058f4'
npm ERR!     at C:\Program Files\nodejs\nod_global\node_modules\npm\node_modules\minipass-fetch\lib\body.js:162:15
npm ERR!     at async [nodeFromEdge] (C:\Program Files\nodejs\nod_global\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:936:19)
npm ERR!     at async [buildDepStep] (C:\Program Files\nodejs\nod_global\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:882:11)
npm ERR!     at async Arborist.buildIdealTree (C:\Program Files\nodejs\nod_global\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:218:7)
npm ERR!     at async Arborist.reify (C:\Program Files\nodejs\nod_global\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\reify.js:134:5)
npm ERR!     at async Install.install (C:\Program Files\nodejs\nod_
  • 验证Newman是否安装成功:
代码语言:python
代码运行次数:0
运行
AI代码解释
复制
'newman' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
  • 问题排查:我们已经安装了node.js了,也已经安装了newman,其他都ok了。但还是不行查看node版本也是好的;
    在这里插入图片描述
    在这里插入图片描述

2.3 解决Newman不是内部命令

  • 根据上边的提示,我们已经做好了很多工作,但是还是不行;
  • 这里需要配置node.js的一些环境变;
  • node.js的安装目录下新建两个文件夹如下node_globalnode_cache
    在这里插入图片描述
    在这里插入图片描述
  • 打开系统环境变量,新增NODE_PATH变量:
代码语言:python
代码运行次数:0
运行
AI代码解释
复制
NODE_PATH
D:\nodejs\node_modules
在这里插入图片描述
在这里插入图片描述
  • 在系统环境变量的path新增:%NODE_PATH%
    在这里插入图片描述
    在这里插入图片描述
  • 打开用户环境变量,修改path中的npm路径为:D:\nodejs\node_global
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
  • 重启电脑、重启电脑、重启电脑(重要的事情说三遍)。
  • 验证newman是否安装成功:
代码语言:python
代码运行次数:0
运行
AI代码解释
复制
newman -h
newman --version
在这里插入图片描述
在这里插入图片描述

3 Newman使用

3.1 Newman如何运行集合?

  • postman中将脚本导出,集合-右键-三个点-【Export】:
    在这里插入图片描述
    在这里插入图片描述
  • 导出为JSON格式文件即可:
    在这里插入图片描述
    在这里插入图片描述
  • 我们导出的文件为:test.postman_collection.json
  • 直接命令行执行以下命令运行脚本:
代码语言:python
代码运行次数:0
运行
AI代码解释
复制
newman run test.postman_collection.json
  • 运行结果如下:
代码语言:python
代码运行次数:0
运行
AI代码解释
复制
C:\Users\Administrator\Desktop>newman run test.postman_collection.json
newman

test

→ zentao
  POST http://127.0.0.1/zentao/api.php/v1/tokens [201 Created, 1.29kB, 1997ms]
  √  状态码为201

┌─────────────────────────┬─────────────────────┬─────────────────────┐
│                         │            executed │              failed │
├─────────────────────────┼─────────────────────┼─────────────────────┤
│              iterations │                   10 │
├─────────────────────────┼─────────────────────┼─────────────────────┤
│                requests │                   10 │
├─────────────────────────┼─────────────────────┼─────────────────────┤
│            test-scripts │                   10 │
├─────────────────────────┼─────────────────────┼─────────────────────┤
│      prerequest-scripts │                   00 │
├─────────────────────────┼─────────────────────┼─────────────────────┤
│              assertions │                   10 │
├─────────────────────────┴─────────────────────┴─────────────────────┤
│ total run duration: 2.1s                                            │
├─────────────────────────────────────────────────────────────────────┤
│ total data received: 44B (approx)                                   │
├─────────────────────────────────────────────────────────────────────┤
│ average response time: 1997ms [min: 1997ms, max: 1997ms, s.d.: 0µs] │
└─────────────────────────────────────────────────────────────────────┘
在这里插入图片描述
在这里插入图片描述

3.2 如何查看帮助文档?

  • 使用以下命令即可:
代码语言:python
代码运行次数:0
运行
AI代码解释
复制
newman -h
或
newman --help
代码语言:python
代码运行次数:0
运行
AI代码解释
复制
C:\Users\Administrator\Desktop>newman -h
Usage: newman [options] [command]

Options:
  -v, --version               output the version number
  -h, --help                  display help for command

Commands:
  run [options] <collection>  Initiate a Postman Collection run from a given URL or path

To get available options for a command:
  newman <command> -h

C:\Users\Administrator\Desktop>newman --help
Usage: newman [options] [command]

Options:
  -v, --version               output the version number
  -h, --help                  display help for command

Commands:
  run [options] <collection>  Initiate a Postman Collection run from a given URL or path

To get available options for a command:
  newman <command> -h

3.3 环境变量设置

  • 脚本文件和环境变量是两个文件;
  • 所以运行脚本的时候如果有环境变量,那么直接加-e--environment即可:
代码语言:python
代码运行次数:0
运行
AI代码解释
复制
newman run 脚本文件 -e 环境变量文件

3.4 关于全局变量

  • 这个和环境变量类似,如果有全局变量,使用-g--globals即可;
代码语言:python
代码运行次数:0
运行
AI代码解释
复制
newman run 脚本文件 -g 全局变量文件

3.5 数据源文件

  • Postman中可以设置迭代次数和数据源文件,而在Newman中使用的话,需要加-d--iteration-data参数指定数据源的路径:
代码语言:python
代码运行次数:0
运行
AI代码解释
复制
newman run 脚本文件 -g 全局变量文件 -d 数据源文件
  • 迭代次数通过-n--iteration-count来确定。

3.6 如何导出变量

  • 直接在命令行加如下参数即可:
代码语言:python
代码运行次数:0
运行
AI代码解释
复制
--export-environment
--export-globals
--export-collection

4 测试报告

  • Newman支持CLI、JSON、HTML、JUNIT等等;
  • 本文主要说下HTML格式的报告使用。

4.1 newman-reporter-html安装

  • newman-reporter-html插件安装:
代码语言:python
代码运行次数:0
运行
AI代码解释
复制
npm install -g newman-reporter-html
在这里插入图片描述
在这里插入图片描述

4.2 newman-reporter-html使用

  • 使用方法:

命令

说明

-r,json,junit

表示指定生成HTML、JSON、XML格式形式的测试报告

--reporter-json-export xxx.json

生成JSON格式的测试报告

--reporter-junit-export xxx.xml

生成XML格式的测试报告

--reporter-html-export xxx.html

生成HTML格式的测试报告

  • 生成的测试报告默认保存到当前目录下,如果报告名称为目录名,则保存到指定目录下;
  • 比如HTML报告:
代码语言:python
代码运行次数:0
运行
AI代码解释
复制
newman run test.postman_collection.json \
-r html --reporter-html-export html_report.html
在这里插入图片描述
在这里插入图片描述
  • 比如XML格式报告:
代码语言:python
代码运行次数:0
运行
AI代码解释
复制
newman run test.postman_collection.json \
-r junit --reporter-junit-export xml_report.xml
在这里插入图片描述
在这里插入图片描述
  • 比如JSON格式报告:
代码语言:python
代码运行次数:0
运行
AI代码解释
复制
newman run test.postman_collection.json \
-r json --reporter-json-export json_report.json
代码语言:python
代码运行次数:0
运行
AI代码解释
复制
{
  "collection": {
    "_": {
      "postman_id": "a1ee2193-7e02-4c50-892f-1e4d706a1132"
    },
    "item": [
      {
        "id": "393ea4b7-bfcf-4e3e-853d-e05a263435bf",
        "name": "zentao",
        "request": {
          "description": {
            "content": "禅道系统接口测试",
            "type": "text/plain"
          },
          "url": {
            "protocol": "http",
            "path": [
              "zentao",
              "api.php",
              "v1",
              "tokens"
            ],
            "host": [
              "127",
              "0",
              "0",
              "1"
            ],
            "query": [],
            "variable": []
          },
          "method": "POST",
          "body": {
            "mode": "raw",
            "raw": "{\"account\": \"admin\", \"password\": \"ZenTao123456\"}",
            "options": {
              "raw": {
                "language": "json"
              }
            }
          }
        },
        "response": [],
        "event": [
          {
            "listen": "test",
            "script": {
              "id": "63fb0da7-27ef-4569-87c6-81697169acf5",
              "type": "text/javascript",
              "exec": [
                "pm.test(\r",
                "    \"状态码为201\",function(){\r",
                "        pm.response.to.have.status(201);\r",
                "    }\r",
                ");"
              ],
              "_lastExecutionId": "9d83ab07-5d8c-4170-bb4f-898dbd965e57"
            }
          }
        ]
      }
    ],
    "event": [],
    "variable": [],
    "info": {
      "_postman_id": "a1ee2193-7e02-4c50-892f-1e4d706a1132",
      "name": "test",
      "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
    }
  },
  "environment": {
    "id": "a4b8954c-a10e-4b54-80d0-bb003c56953e",
    "values": []
  },
  "globals": {
    "id": "a084d77b-cbf5-4498-9770-200d6e0a4168",
    "values": []
  },
  "run": {
    "stats": {
      "iterations": {
        "total": 1,
        "pending": 0,
        "failed": 0
      },
      "items": {
        "total": 1,
        "pending": 0,
        "failed": 0
      },
      "scripts": {
        "total": 1,
        "pending": 0,
        "failed": 0
      },
      "prerequests": {
        "total": 1,
        "pending": 0,
        "failed": 0
      },
      "requests": {
        "total": 1,
        "pending": 0,
        "failed": 0
      },
      "tests": {
        "total": 1,
        "pending": 0,
        "failed": 0
      },
      "assertions": {
        "total": 1,
        "pending": 0,
        "failed": 0
      },
      "testScripts": {
        "total": 1,
        "pending": 0,
        "failed": 0
      },
      "prerequestScripts": {
        "total": 0,
        "pending": 0,
        "failed": 0
      }
    },
    "timings": {
      "responseAverage": 154,
      "responseMin": 154,
      "responseMax": 154,
      "responseSd": 0,
      "dnsAverage": 0,
      "dnsMin": 0,
      "dnsMax": 0,
      "dnsSd": 0,
      "firstByteAverage": 0,
      "firstByteMin": 0,
      "firstByteMax": 0,
      "firstByteSd": 0,
      "started": 1700804595902,
      "completed": 1700804596169
    },
    "executions": [
      {
        "cursor": {
          "position": 0,
          "iteration": 0,
          "length": 1,
          "cycles": 1,
          "empty": false,
          "eof": false,
          "bof": true,
          "cr": false,
          "ref": "1d6d4e14-53d2-4ab6-8e78-87c67bad8bc9",
          "httpRequestId": "b5949fe3-d241-4020-a10c-b4adcbef9bb1"
        },
        "item": {
          "id": "393ea4b7-bfcf-4e3e-853d-e05a263435bf",
          "name": "zentao",
          "request": {
            "description": {
              "content": "禅道系统接口测试",
              "type": "text/plain"
            },
            "url": {
              "protocol": "http",
              "path": [
                "zentao",
                "api.php",
                "v1",
                "tokens"
              ],
              "host": [
                "127",
                "0",
                "0",
                "1"
              ],
              "query": [],
              "variable": []
            },
            "method": "POST",
            "body": {
              "mode": "raw",
              "raw": "{\"account\": \"admin\", \"password\": \"ZenTao123456\"}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "id": "63fb0da7-27ef-4569-87c6-81697169acf5",
                "type": "text/javascript",
                "exec": [
                  "pm.test(\r",
                  "    \"状态码为201\",function(){\r",
                  "        pm.response.to.have.status(201);\r",
                  "    }\r",
                  ");"
                ],
                "_lastExecutionId": "9d83ab07-5d8c-4170-bb4f-898dbd965e57"
              }
            }
          ]
        },
        "request": {
          "description": {
            "content": "禅道系统接口测试",
            "type": "text/plain"
          },
          "url": {
            "protocol": "http",
            "path": [
              "zentao",
              "api.php",
              "v1",
              "tokens"
            ],
            "host": [
              "127",
              "0",
              "0",
              "1"
            ],
            "query": [],
            "variable": []
          },
          "header": [
            {
              "key": "Content-Type",
              "value": "application/json",
              "system": true
            },
            {
              "key": "User-Agent",
              "value": "PostmanRuntime/7.33.0",
              "system": true
            },
            {
              "key": "Accept",
              "value": "*/*",
              "system": true
            },
            {
              "key": "Cache-Control",
              "value": "no-cache",
              "system": true
            },
            {
              "key": "Postman-Token",
              "value": "4dd31771-a07b-42e8-b78a-ac244c4dca6c",
              "system": true
            },
            {
              "key": "Host",
              "value": "127.0.0.1",
              "system": true
            },
            {
              "key": "Accept-Encoding",
              "value": "gzip, deflate, br",
              "system": true
            },
            {
              "key": "Connection",
              "value": "keep-alive",
              "system": true
            },
            {
              "key": "Content-Length",
              "value": "48",
              "system": true
            }
          ],
          "method": "POST",
          "body": {
            "mode": "raw",
            "raw": "{\"account\": \"admin\", \"password\": \"ZenTao123456\"}",
            "options": {
              "raw": {
                "language": "json"
              }
            }
          }
        },
        "response": {
          "id": "2a26af66-ad21-42d2-8b7a-b89cd7339a47",
          "status": "Created",
          "code": 201,
          "header": [
            {
              "key": "Date",
              "value": "Fri, 24 Nov 2023 05:43:16 GMT"
            },
            {
              "key": "Server",
              "value": "Apache"
            },
            {
              "key": "Set-Cookie",
              "value": "zentaosid=9f0dab6ebbe1e65c99a8abb3c351d89a; path=/zentao/; HttpOnly"
            },
            {
              "key": "Set-Cookie",
              "value": "lang=zh-cn; expires=Sun, 24-Dec-2023 05:43:16 GMT; Max-Age=2592000; path=/zentao/"
            },
            {
              "key": "Set-Cookie",
              "value": "device=desktop; expires=Sun, 24-Dec-2023 05:43:16 GMT; Max-Age=2592000; path=/zentao/; HttpOnly"
            },
            {
              "key": "Set-Cookie",
              "value": "theme=default; expires=Sun, 24-Dec-2023 05:43:16 GMT; Max-Age=2592000; path=/zentao/"
            },
            {
              "key": "Expires",
              "value": "Thu, 19 Nov 1981 08:52:00 GMT"
            },
            {
              "key": "Cache-Control",
              "value": "private"
            },
            {
              "key": "Pragma",
              "value": "no-cache"
            },
            {
              "key": "X-Content-Type-Options",
              "value": "nosniff"
            },
            {
              "key": "X-XSS-Protection",
              "value": "1; mode=block"
            },
            {
              "key": "Strict-Transport-Security",
              "value": "max-age=3600; includeSubDomains"
            },
            {
              "key": "Referrer-Policy",
              "value": "no-referrer-when-downgrade"
            },
            {
              "key": "X-Permitted-Cross-Domain-Policies",
              "value": "master-only"
            },
            {
              "key": "X-Download-Options",
              "value": "noopen"
            },
            {
              "key": "Content-Security-Policy",
              "value": "form-action 'self';connect-src 'self';"
            },
            {
              "key": "X-Frame-Options",
              "value": "SAMEORIGIN"
            },
            {
              "key": "Access-Control-Allow-Origin",
              "value": "*"
            },
            {
              "key": "Access-Control-Allow-Credentials",
              "value": "true"
            },
            {
              "key": "Access-Control-Allow-Headers",
              "value": "Origin,X-Requested-With,Content-Type,Accept,Authorization,Token,Referer,User-Agent"
            },
            {
              "key": "Access-Control-Allow-Methods",
              "value": "GET,POST,PUT,DELETE,OPTIONS,PATCH"
            },
            {
              "key": "Content-Length",
              "value": "44"
            },
            {
              "key": "Keep-Alive",
              "value": "timeout=10, max=100"
            },
            {
              "key": "Connection",
              "value": "Keep-Alive"
            },
            {
              "key": "Content-Type",
              "value": "application/json"
            }
          ],
          "stream": {
            "type": "Buffer",
            "data": [
              123,
              34,
              116,
              111,
              107,
              101,
              110,
              34,
              58,
              34,
              57,
              102,
              48,
              100,
              97,
              98,
              54,
              101,
              98,
              98,
              101,
              49,
              101,
              54,
              53,
              99,
              57,
              57,
              97,
              56,
              97,
              98,
              98,
              51,
              99,
              51,
              53,
              49,
              100,
              56,
              57,
              97,
              34,
              125
            ]
          },
          "cookie": [],
          "responseTime": 154,
          "responseSize": 44
        },
        "id": "393ea4b7-bfcf-4e3e-853d-e05a263435bf",
        "assertions": [
          {
            "assertion": "状态码为201",
            "skipped": false
          }
        ]
      }
    ],
    "transfers": {
      "responseTotal": 44
    },
    "failures": [],
    "error": null
  }
}
  • 以下是生成的几个报告:
    在这里插入图片描述
    在这里插入图片描述

4.3 htmlextra安装

  • htmlextra主要实现比较高级的测试报告,需要进行安装:
代码语言:python
代码运行次数:0
运行
AI代码解释
复制
npm install -g newman-reporter-htmlextra
在这里插入图片描述
在这里插入图片描述

4.4 htmlextra使用

  • 使用方法和newman-reporter-html基本一样;
  • 使用命令方法:
代码语言:python
代码运行次数:0
运行
AI代码解释
复制
newman run test.postman_collection.json -r \
htmlextra --reporter-html-export html_report.html
  • 执行命令后会在当前目录或者指定目录生成一个newman文件夹,文件夹中保存着生成的文报告信息;
  • 测试报告样式如下:
    在这里插入图片描述
    在这里插入图片描述

5 关于postman使用

  • 这个之前的文章已经介绍了,直接去浏览即可,这里不再赘述;
  • 大概思路就是使用postman生成接口数据,导出来后使用Newman运行和生成测试报告。

我正在参与2023腾讯技术创作特训营第三期有奖征文,组队打卡瓜分大奖!

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
暂无评论
推荐阅读
编辑精选文章
换一批
Postman+Newman+Git+Jenkins实现接口自动化测试持续集成
做接口测试的话,首先要考虑的是如何选择一个合适的工具?在忽略工具是否好用,是否能满足业务要求的前提下,需要考虑以下2点:
小博测试成长之路
2021/03/08
2.4K0
Postman+Newman+Git+Jenkins实现接口自动化测试持续集成
接口自动化测试Postman+Newman+Jenkins
Postman可以做接口测试,简单易用很容易上手。但是由于项目的接口越来越多,每次执行都要手动点击,使得执行起来不是很灵活。
wangmcn
2022/07/25
1.7K0
接口自动化测试Postman+Newman+Jenkins
postman自动化+newman+jenkins
一、 postman自动化介绍 postman自动化集成jenkins项目,postman做单接口测试非常方便, 所以就尝试着去做了一次postman+nweman+jenkins的持续集成项目。 二、 项目软件 postman+node+newman+jenkins 三、 安装 1. 安装postman客户端 2. 安装node.js 3. 安装newman: npm -g install newman 四、 使用说明 1. 创建postman collection 2. 加入test断言
懿曲折扇情
2022/10/31
3210
postman自动化+newman+jenkins
postman系列(六):使用newman来执行postman脚本
通过之前的了解,我们知道postman是基于javascript语言编写的,而导出的json格式的postman脚本也无法直接在服务器运行;
冰霜
2022/03/15
1.7K0
postman系列(六):使用newman来执行postman脚本
API接口测试-postman自动生成测试报告
主要分享测试的学习资源,帮助快速了解测试行业,帮助想转行、进阶、小白成长为高级测试工程师。
伤心的辣条
2022/12/14
8970
API接口测试-postman自动生成测试报告
使用postman 自动化测试接口
软件测试是软件开发的重要组成部分,是贯穿整个软件生命周期,对软件产品进行验证和确认的活动过程,其目的是尽早发现软件产品中存在的各种问题,如与用户需求、预先定义不一致等问题。
狂奔滴小马
2021/11/15
1K0
使用postman 自动化测试接口
postman+newman框架之生成接口测试报告
做测试的同仁,对于接口测试的都应该了解,接口测试不简单的是在开发时期,开发已写完完备的接口文档进行测试就完事的。 而是需要在项目的持续迭代的过程中持续测试的;那么我们是一个一个接口参考文档去输出用例,手动执行,整理结果吗? 当然是NO。那样的你应该也不是一个"快乐的鼠标工程师" 鼠标工程师的内心,每次点点点、每次上线;都耗费巨大的时间成本以及心态更方面的准备,去保证测试完成的质量,这就是为什么这么多人喜欢学习自动化测试的根本原因 所以手动去一个一个去执行接口,人力时间成本太高,接口的自动化测试环节就是比不可少了。 那么,由此即可以引出接口自动化测试的实现方式。实现方式会有多种多样,比如说已经比较成熟的第三方“商业版”测试工具SoupUI、postman 第一次接触是以chrome插件版形式去认识的postman,现在已经独立为单独的app、但是今天我要重点说的是postman的插件–newman。 前置条件: 前提是已经安装好node程序 node检验方式:打开cmd-->输入node 进入命令行即可
测试小兵
2019/09/08
3K0
Linux安装newman生成postman脚本报告
1、安装node # 1、下载node wget https://nodejs.org/dist/v16.9.1/node-v16.9.1-linux-x64.tar.xz # 2、解压 tar -xvf node-v16.9.1-linux-x64.tar.xz # 3.重命名 mv node-v16.9.1-linux-x64 node 2、配置环境变量 # 1、编辑环境变量文件 vim /etc/profile # 2、添加node环境 export NODE_HOME=/usr/local
cywhat
2022/11/22
9480
使用Postman工具做接口测试(四)——参数化、执行用例与生成测试报告(完结篇)
  在之前介绍《使用Postman工具做接口测试(二)——环境变量与请求参数格式》文中讲过环境变量的设置,其实就是参数化,现在,我介绍参数化其他几种形式。
全栈测试开发日记
2023/02/02
2.9K0
使用Postman工具做接口测试(四)——参数化、执行用例与生成测试报告(完结篇)
编写自己的newman reporter
newman时一款基于Node.js开发的可以运行postman的工具,使用Newman可以直接从命令行运行postman集合。更多介绍可以参看这里。
跑马溜溜的球
2020/12/07
8030
Postman Newman:提升你的 API 测试效率
Postman Newman 是一个 CLI(命令行界面)工具,可以使用它来运行 Postman 中的集合(Collection)和环境(Environment)进行自动化测试。它是 Postman 的命令行 Collection Runner,能够直接从命令行运行 Postman 集合。使用 Newman 可以测试 API 的功能、性能、可靠性和安全性,同时可以将测试结果输出成多种格式的报告,例如 HTML、JSON、JUnit 等,以方便开发人员进行问题定位和分析。
物立
2023/06/15
4050
Postman Newman:提升你的 API 测试效率
Postman使用教程详解「建议收藏」
Postman下载网址: https://www.postman.com/downloads/
全栈程序员站长
2022/09/04
3.1K0
Postman使用教程详解「建议收藏」
Postman+newman生成接口测试报告学习笔记
Postman是用于API开发的协作平台。Postman的功能简化了构建API的每个步骤并简化了协作,因此您可以更快地创建更好的API。
wencheng
2020/07/20
7740
Postman+newman生成接口测试报告学习笔记
newman生成好看的html报告
PS:运行newman需要node 版本大于10 1.安装newman npm install -g newman 2.安装普通html报告插件(建议安装) npm install -g newman-reporter-html 3.安装美化html插件 npm install -g newman-reporter-htmlextra 4.newman命令详解 newman run SX.postman_collection.json -e environment.json -r htmlextra,cl
cywhat
2022/11/22
3.5K2
newman生成好看的html报告
接口02_精通Postman接口测试
一、接口关联,接口依赖 下一个接口的参数是使用的上一个接口的返回值? 接口测试,接口自动化。 1.JSON提取器。(都是从返回值里面提取) 1 //javascript脚本,var定义变量 2 //打印responseBody返回值 3 console.log(responseBody) 4 //使用json提取器把responseBody返回值转化成一个字典。 5 var jd = JSON.parse(responseBody) 6 //提取access_token,并且设置为全局变量(就是在任何接口
测试小能手
2022/11/07
1K0
postman接口测试
postman提供功能强大的 Web API 和 HTTP 请求的调试,它能够发送任何类型的HTTP 请求 (GET, POST, PUT, DELETE...),并且能附带任何数量的参数和 Headers.不仅如此,它还提供测试数据和环境配置数据的导入导出,付费的Post Cloud用户还能够创建自己的Team Library用来团队协作式的测试,并能够将自己的测试收藏夹和用例数据分享给团队.
测试加
2022/03/24
9750
postman接口测试
Postman高级用法-接口自动化
用newman最主要的原因是postman无法自动多次运行某个collection
沈宥
2022/05/09
5570
Postman高级用法-接口自动化
Jenkins 集成postman 自动化运行接口测试用例
做过接口测试的人,应该都知道postman ,我们在日常的时候都可以利用postman做接口测试,我们可以把接口的case保存下来在collection里面,那么可能会有这样的需求,我们怎么把collection的用例放到jenkins中定时执行呢,今天我们就来看下如何实现的。
雷子
2021/03/15
9610
Jenkins 集成postman 自动化运行接口测试用例
postman的命令执行工具--newman
newman时一款基于Node.js开发的可以运行postman的工具,使用Newman可以直接从命令行运行postman集合。
跑马溜溜的球
2020/12/07
1.3K0
postman的命令执行工具--newman
postman系列(七):测试脚本集成到jenkins
准备工作:一台linux服务器(可以用虚拟机搭建一个),linux服务器上安装好node.js、newman,部署好jenkins
冰霜
2022/03/15
7230
postman系列(七):测试脚本集成到jenkins
推荐阅读
相关推荐
Postman+Newman+Git+Jenkins实现接口自动化测试持续集成
更多 >
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
本文部分代码块支持一键运行,欢迎体验
本文部分代码块支持一键运行,欢迎体验