Newman+postman输出report

  • 下载安装nodejs:http://nodejs.cn/download/
  • 安装Newman:npm install -g newman
  • 安装HTML报告:npm install -g newman-reporter-html
  • Newman简单用法
    1、运行从postman导出的json/上传到服务器的url
    newman run [options] <collection> URL or path to a Postman Collection
    

      

    2、输出报告时使用的命令:
    -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格式的测试报告
    默认生成的测试报告保存在当前目录下,如果文件名前加上路径,则保存在指定的目录下
    

     例如输出json和html文件报告:

    newman run APITest.postman_collection.json -r html,json --reporter-json-export jsonReport.json --reporter-html-export htmlReport.html
    

      
    3、指定环境/全局变量路径

    指定环境变量路径:-e source
    指定全局变量路径:-g source

    例如:

    newman run ~/Desktop/example.postman_collection.json -e ~/Desktop/DEV.postman_environment.json -g ~/Desktop/global.postman_collection.json


    4、设置重复执行次数

    newman run APITest.postman_collection.json -n 次数
    

      
    5、查看其它可用参数

    newman run -h
    

      

    # 命令介绍
    
    newman run   用例名称   [-e | -r | -d  | -g  -n  - export-environment | -timeout (ms)   | -timeport-request (ms)  | -timeout-script (ms)]
    
    # -e 环境变量地址
    
    # -r 生成报告格式
    
    # -d 需要用的测试数据
    
    # -g 全局变量地址
    
    # -n  迭代执行几次
    
    # -export-environment  导出文件执行的环境变量路径
    
    # -timeout (ms)  设置整个集合运行完成执行的时间
    
    # –timeport-request (ms)   指定等待请求返回响应的时间
    
    # -timeout-script (ms)指定等待脚本执行完成的时间

     

  • htmlextra 使用

    htmlextra套件生成相对好看的html报告,执行命令:

    npm install -g newman-reporter-htmlextra
    

    命令行中执行命令生成测试报告

    newman run APITest.postman_collection.json -r htmlextra --reporter-html-export htmlReport.html

     

posted @ 2020-07-01 14:56  牵猫溜狗  阅读(643)  评论(0编辑  收藏  举报