Postman測試報告的生成方法
我們使用工具newman就可以生成測試報告(自動化測試的結(jié)果)
Newman是一款基于nodejs開發(fā)的可以運行postman腳本的工具,使用Newman,可以直接從命令運行和測試postman集合。
使用newman的前提是需要安裝node.js,通過node.js來安裝newman的工具
安裝newman的命令:
npm install -g newman --registry=https://registry.npm.taobao.org
1.安裝node.js
下載地址:https://nodejs.org/en/download/下載適合自己電腦的版本,這里我們使用Windows平臺
安裝:只需雙擊即可完成安裝,在這里建議不要將路徑放到C盤,這是一種安裝軟件的共識。并且在安裝的過程中,安裝向?qū)б呀?jīng)幫我們完成了環(huán)境變量的注冊,我們可以通過環(huán)境變量來查看
驗證是否配置成功:控制臺輸入npm,如果顯示以下數(shù)據(jù)則表示安裝并且配置成功
C:\Users\特昂糖>npm npm <command> Usage: npm install install all the dependencies in your project npm install <foo> add the <foo> dependency to your project npm test run this project's tests npm run <foo> run the script named <foo> npm <command> -h quick help on <command> npm -l display usage info for all commands npm help <term> search for help on <term> (in a browser) npm help npm more involved overview (in a browser) All commands: access, adduser, audit, bin, bugs, cache, ci, completion, config, dedupe, deprecate, diff, dist-tag, docs, doctor, edit, exec, explain, explore, find-dupes, fund, get, help, hook, init, install, install-ci-test, install-test, link, ll, login, logout, ls, org, outdated, owner, pack, ping, pkg, prefix, profile, prune, publish, rebuild, repo, restart, root, run-script, search, set, set-script, shrinkwrap, star, stars, start, stop, team, test, token, uninstall, unpublish, unstar, update, version, view, whoami Specify configs in the ini-formatted file: C:\Users\特昂糖\.npmrc or on the command line via: npm <command> --key=value More configuration info: npm help config Configuration fields: npm help 7 config npm@8.1.2 D:\Ruanjian\node_modules\npm #這里顯示的是軟件所在本地磁盤路徑
2.安裝newman
node.js配置成功后我們就可以安裝newman了,安裝newman的命令為:npm install -g newman --registry=https://registry.npm.taobao.org
C:\Users\特昂糖>npm install -g newman --registry=https://registry.npm.taobao.org 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. 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. 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 128 packages in 13s npm notice npm notice New minor version of npm available! 8.1.2 -> 8.3.0 npm notice Changelog: https://github.com/npm/cli/releases/tag/v8.3.0 npm notice Run npm install -g npm@8.3.0 to update! npm notice
驗證是否安裝成功:
C:\特昂糖>newman 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.控制臺生成測試報告
首先在postman中導(dǎo)出測試數(shù)據(jù)
這里以我的為例,下載地址:http://xiazai.jb51.net/202201/yuanma/postman_collection_jb51.rar
控制臺進(jìn)入導(dǎo)出文件所在本地磁盤路徑
生成測試報告
newman run ?+導(dǎo)出的測試數(shù)據(jù)文件名稱
4.生成HTML的測試報告
安裝HTML套件 newman 支持四種格式報告文件:cli,json,html,junit 生成 html 報告時需要安裝html套件,命令行中執(zhí)行: npm install -g newman-reporter-html ? ? ?輸出報告時使用的命令: -r html,json,junit ? ? ? ? 指定生成html,json,xml形式的測試報告 --reporter-json-export jsonReport.json ? ? ? ? ?生成json格式的測試報告 --reporter-junit-export xmlReport.xml ? ? ? ? ? ?生成xml格式的測試報告 --reporter-html-export htmlReport.html ? ? ? ? ?生成html格式的測試報告 默認(rèn)生成的測試報告保存在當(dāng)前目錄下,如果文件名前加上路徑,則保存在指定的目錄下 例:輸出json和html文件報告
生成html測試報告
輸出命令: newman run 風(fēng)暴平臺.postman_collection.json -r html
5.輸出htmlextra報告
安裝htmlextra套件
npm install -g newman-reporter-htmlextra
運行htmlextra套件
newman run 風(fēng)暴平臺.postman_collection.json -r htmlextra
結(jié)果展示
到此這篇關(guān)于Postman測試報告的生成的文章就介紹到這了,更多相關(guān)Postman測試報告內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Postman全局注冊方法及對返回數(shù)據(jù)可視化處理
這篇文章主要為大家介紹了Postman全局注冊方法及對返回數(shù)據(jù)可視化處理詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-02-02快速解決eclipse中注釋的代碼依然會執(zhí)行的問題
下面小編就為大家?guī)硪黄焖俳鉀Qeclipse中注釋的代碼依然會執(zhí)行的問題。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-12-12