日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

postman进阶之Newman,从安装到使用到填坑,不废话

發(fā)布時(shí)間:2024/4/15 编程问答 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 postman进阶之Newman,从安装到使用到填坑,不废话 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

NEWMAN--postman命令行工具

安裝

  • 安裝node.js 參考node.js安裝指導(dǎo)
  • 命令行工具執(zhí)行?npm install -g newman
  • 檢查:newman -v
  • 執(zhí)行命令:newman run <collection-file-source> [options]
  • 使用報(bào)錯(cuò)集錦

    輸入命令報(bào)錯(cuò)

    error: unknown option `--export-globals'

    • 解決辦法:導(dǎo)出全局變量使用關(guān)鍵字 -G

    無法生成報(bào)告

    error creating path for file "newman\newman-run-report-2018-02-24-02-48-21-707-0.html" for html-reporter EEXIST: file already exists, mkdir 'C:\Users\xxx\AppData\Roaming\npm\newman'

    • 解決辦法:newman默認(rèn)在執(zhí)行命令的當(dāng)前目錄下的/newman目錄下生成當(dāng)前時(shí)間變量的測試報(bào)告,所以保證當(dāng)前目錄下有此文件夾即可。 如下述命令,需保證在C:\Users\xxx路徑下有newman文件夾,而不受C:\Users\xxx\AppData\newman影響

    C:\Users\xxx>newman -c C:\Users\xxx\Desktop\1.postmancollection.json -g C:\Users\xxx\AppData\Local\Postman\env\globals.postmanglobals.json -G C:\Users\xxx\AppData\Local\Postman\env\tempGlobalEnvtempGEnv.json -H C:\Users\xxx\AppData\newman

    以上為newman V2命令,V3如下:

    C:\Users\xxx>newman run C:\Users\xxx\Desktop\1.postmancollection.json --globals C:\Users\xxx\AppData\Local\Postman\env\globals.postmanglobals.json --export-globals C:\Users\xxx\AppData\Local\Postman\env\tempGlobalEnv\tempGEnv.json --reporters cli,html,json,junit --reporter-json-export jsonOut.json --reporter-junit-export xmlOut.xml --reporter-html-export htmlOutput.html

    注意:cmd命令行執(zhí)行命令時(shí),--reporters cli,html,json,junit后如果帶上所有格式的報(bào)告導(dǎo)出命令,則生成不了報(bào)告,即要生成某種格式的報(bào)告(如生成HTML格式報(bào)告),則不要寫該格式的命令(則寫--reporters cli,html,json,junit --reporter-json-export jsonOut.json --reporter-junit-export xmlOut.xml?即可生成HTML格式的報(bào)告)

    但是在Jenkins中配置時(shí)則無此規(guī)則,寫什么格式生成什么格式的報(bào)告,還有不同的則是無法自動生成對應(yīng)時(shí)間格式的報(bào)告。如下Jenkins版本

    newman run C:\Users\xxx\Desktop\1.postmancollection.json --globals C:\Users\xxx\AppData\Local\Postman\env\globals.postmanglobals.json --export-globals C:\Users\xxx\AppData\Local\Postman\env\tempGlobalEnv\tempGEnv.json --reporters cli,html,json,junit --reporter-json-export C:\Users\xxx\newman\newman-run-report-system.date.json --reporter-junit-export C:\Users\xxx\newman\newman-run-report-system.date.xml --reporter-html-export C:\Users\xxx\newman\newman-run-report-{{date}}.html

    常用命令

  • 獲取幫助?newman -h
    詳見newman官方文檔

  • 導(dǎo)入導(dǎo)出變量newman -c <collection-file-source> -g(導(dǎo)入全局變量)<path> -e(導(dǎo)入環(huán)境變量)<path> -G(導(dǎo)出全局變量)<path> -E(導(dǎo)出環(huán)境變量)<path>e.g

    C:\Users\xxx\AppData\Roaming\npm>newman -c C:\Users\xxx\Desktop\1.postmancollection.json -g C:\Users\xxx\AppData\Local\Postman\env\globals.postmanglobals.json -G C:\Users\xxx\AppData\Local\Postman\env\tempGlobalEnv\tempGEnv.json

  • 循環(huán)?newman -c <collection-file-source> -n num(循環(huán)次數(shù))

  • 輸出報(bào)告?newman -c <collection-file-source> -H<path>?e.g

  • C:\Users\xxx>newman run C:\Users\xxx\Desktop\1.postmancollection.json --globals C:\Users\xxx\AppData\Local\Postman\env\globals.postmanglobals.json --export-globals C:\Users\xxx\AppData\Local\Postman\env\tempGlobalEnv\tempGEnv.json --reporters cli,html,json,junit --reporter-json-export jsonOut.json --reporter-junit-export xmlOut.xml --reporter-html-export htmlOutput.html

    轉(zhuǎn)載于:https://www.cnblogs.com/teresa135/p/9405825.html

    總結(jié)

    以上是生活随笔為你收集整理的postman进阶之Newman,从安装到使用到填坑,不废话的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。