zoukankan      html  css  js  c++  java
  • newman使用

    简介:

      Newman 是 Postman 推出的一个 nodejs 库,直接来说就是 Postman 的json文件可以在命令行执行的插件。
      Newman 可以方便地运行和测试集合,并用之构造接口自动化测试和持续集成。

    安装:

      1.先下载并安装Node.js,下载地址:https://nodejs.org/en/

      2.打开cmd,输入node,显示“>”,说明node安装成功;

      3.安装newman,打开cmd,输入npm install -g newman

      4.通过查看newman版本测试安装是否成功,打开cmd,输入newman -v,出现版本信息即安装成功;

    newman使用:

     1.newman run 集合名/url地址:运行一个集合,url地址为集合文件导出的url

    // newman run 集合名
    newman run sample.postman_collection.json
    // newman run url地址
    newman run https://www.getpostman.com/collections/c1454cb35

     2.-e/-environment 环境文件路径

    // newman run 集合名 -e 环境路径
    newman run sample.postman_collection_hava_environment.json -e ..env正式环境.postman_environment.json
    // newman run 集合名 --environment 环境路径
    newman run sample.postman_collection_hava_environment.json --environment ..env正式环境.postman_environment.json

    3.-g/--globals 全局变量路径文件

    // newman run 集合名 -e 环境路径文件 -g 全局变量路径文件
    newman run sample.postman_collection_hava_environment.json -e ..env正式环境.postman_environment.json -g ..envmy_postman_globals.json
    // newman run 集合名 -e 环境路径文件 --globals 全局变量路径文件
    newman run sample.postman_collection_hava_environment.json -e ..env正式环境.postman_environment.json --globals ..envmy_postman_globals.json

    4.-d/--iteration-data 指定用于迭代的数据源文件路径

    // newman run 集合名 -e 环境路径文件 -d 测试数据源文件路径
    newman run sample.postman_collection_hava_environment_word_data.json -e ..env正式环境.postman_environment.json -d ..	estdata	est_data.csv
    // newman run 集合名 -e 环境路径文件 --iteration-data 测试源文件路径
    newman run sample.postman_collection_hava_environment_word_data.json -e ..env正式环境.postman_environment.json --iteration-data ..	estdata	est_data.csv

    5.-n,--iteration-count 指定迭代次数

    // newman run 集合名 -e 环境路径文件 -d 测试源文件路径 -n 迭代次数
    newman run sample.postman_collection_hava_environment_word_data.json -e ..env正式环境.postman_environment.json -d ..	estdata	est_data.csv -n 3
    // newman run 集合名 -e 环境路径文件 -d 测试源文件路径 --iteration-count 迭代次数
    newman run sample.postman_collection_hava_environment_word_data.json -e ..env正式环境.postman_environment.json -d ..	estdata	est_data.csv --iteration-count 3

    6.--folder 运行集合中指定的文件夹

    // newman run 集合名 -e 环境路径文件 -d 测试源文件路径 -n 迭代次数 --folder 集合中指定的文件夹
     newman run sample.postman_collection_hava_environment_word_data.json -e ..env正式环境.postman_environment.json -d ..	estdata	est_data.csv --folder test_suit_01

    7.--timeout 设置整个集合运行完成执行的时间,单位ms

    // newman run 集合名 -e 环境路径文件 -d 测试源文件路径 -n 迭代次数 --folder集合中指定的文件夹 --timeout 整个集合运行完成执行的时间(单位ms)
    newman run sample.postman_collection_hava_environment_word_data.json -e ..env正式环境.postman_environment.json -d ..	estdata	est_data.csv -n 3 --folder test_suit_01 --timeout 5000

    8.-r,--reporter 指定用于此次运行的报告类型xml,json,junit,html,htmlextra

    • --reporter-json-export jsonReport.json:生成json格式的测试报告
    • --reporter-junit-export  xmlReport.xml:生成xml格式的次测试报告
    • --reporter-html-export htmlReport.html:生成html格式的测试报告
    • --reporter-htmlextra-export htmlReport.html:生成htmlextra格式的测试报告
    //newman run 集合名 -e 环境路径文件 -d 测试源文件路径 -r 报告格式 --reporter-junit-export 生成文件路径和文件名
    newman run sample.postman_collection_hava_environment_word_data.json -e ..env正式环境.postman_environment.json -d ..	estdata	est_data.csv -r json --reporter-json-export ..
    eportsjsonTestReport.json

    如果需要一次性生成多份报告

    //newman run 集合名 -e 环境路径文件 -d 测试源文件路径 -r 报告格式,报告格式 --reporter-json-export 生成文件路径和文件名 --reporter-html-export 生成文件路径和文件名
    newman run sample.postman_collection_hava_environment_word_data.json -e ..env正式环境.postman_environment.json -d ..	estdata	est_data.csv -n 4 -r json,html --reporter-json-export ..
    eportsjsonReport.json --reporter-html-export ..
    eportshtmlReport.html
  • 相关阅读:
    第八章 多线程编程
    Linked List Cycle II
    Swap Nodes in Pairs
    Container With Most Water
    Best Time to Buy and Sell Stock III
    Best Time to Buy and Sell Stock II
    Linked List Cycle
    4Sum
    3Sum
    Integer to Roman
  • 原文地址:https://www.cnblogs.com/ClownAlin/p/13035947.html
Copyright © 2011-2022 走看看