【问题标题】:How to append Newman htmlextra results to existing htmlextra report file如何将 Newman htmlextra 结果附加到现有的 htmlextra 报告文件
【发布时间】:2020-03-13 19:54:05
【问题描述】:

我有两个 Newman 命令

  1. newman run collection.json -e env.json --folder create_clients -d clients.csv -r htmlextra --htmlreporter-export reporter.html

  2. newman run collection.json -e env.json --folder create_orders -d orders.csv -r htmlextra --htmlreporter-export reporter.html

在命令 #2 执行之后,reporter.html 被覆盖,我希望结果被追加。

有没有可能,请指教,谢谢。

【问题讨论】:

    标签: postman newman


    【解决方案1】:

    记者不是这样工作的。您无法附加上一次运行的结果,因为它会再次创建全新的报告。

    从上下文来看,这是 2 个不同的 Collection 运行。如果您要在应用程序中运行它们并在 Runner 中查看结果,那将是相同的。

    如果您想单独查看两个报告,则需要在导出时为它们指定不同的名称,或删除export 标志,默认文件名将在/newman 目录中创建。

    【讨论】:

      【解决方案2】:

      --htmlreporter-export reporter.html 参数告诉 newman 将 html 报告保存在名为 reporter.html 的文件中,因此每次运行命令时,此文件都会被覆盖。

      如果您需要使用不同的名称保存文件,您可以尝试为其名称添加时间戳。在 unix 系统上,您可以尝试以下操作:

      --htmlreporter-export reporter-`date +'%y-%m-%d-%H-%M-%S'`.html
      

      这将在文件名中附加date 命令的输出(格式为年-月-日-时-分-秒数字字符串),因此如果您的命令运行超过一秒,每个结果将位于不同的文件中(您当然可以添加 -%N 来获得纳秒,或者添加 man date 来寻找其他有用的值!)。

      但是,您知道,使用标准输出是一个很好的做法:使用 newman 的每个人都希望找到结果为 newman/newman-run-report-[date].[json|xml|html],所以除非您非常需要在其他地方获取结果,否则请保持简单,不要重新发明轮子:-)

      【讨论】:

        猜你喜欢
        • 2021-12-27
        • 2021-09-09
        • 1970-01-01
        • 2023-03-10
        • 1970-01-01
        • 2021-11-27
        • 1970-01-01
        • 2021-08-30
        • 1970-01-01
        相关资源
        最近更新 更多