【问题标题】:Newman: Html output file is not generated when I try to run a newman command using PHPNewman:当我尝试使用 PHP 运行 newman 命令时,未生成 Html 输出文件
【发布时间】:2019-11-26 06:19:53
【问题描述】:

我有以下 newman 命令:

newman run "collection.json" -e "environment.json"   --reporters html,cli  --reporter-html-template ~/node_modules/newman-reporter-html/lib/template-default.hbs --reporter-html-export test_result.html --delay-request 1500

我将上面的命令保存在 test.sh 文件中。当我将文件作为 ./test.sh 运行时,它会生成 html 输出,但是当从 php 文件运行相同的文件时,它不会生成 html 文件。

下面是我的php文件

<?
$cmd = file_get_contents("test.sh");
while (@ ob_end_flush()); // end all output buffers if any

$proc = popen($cmd, 'r');
echo '<pre>';
while (!feof($proc))
{
    echo fread($proc, 4096);
    @ flush();
}
echo '</pre>';
?>

这个 php 文件执行 newman 命令并在浏览器窗口中打印终端的实时输出。执行后,它应该生成 html 文件,但它不会。谁能帮我指出我做错了什么或者还有其他 newman 命令吗?

【问题讨论】:

    标签: php html postman postman-collection-runner newman


    【解决方案1】:

    找到解决方案: 从 newman 命令中删除 --reporter-html-template ~/node_modules/newman-reporter-html/lib/template-default.hbs 参数或将 template-default.hbs 文件保留在 .sh 文件所在的同一目录中放置。

    【讨论】:

      猜你喜欢
      • 2015-10-12
      • 2015-12-18
      • 2019-07-20
      • 2021-09-09
      • 2019-04-11
      • 2022-01-19
      • 2019-09-11
      • 2022-09-26
      • 2021-12-26
      相关资源
      最近更新 更多