我如何在拆卸线程中使用 Bean shell 采样器在 JMeter 中创建 HTML 报告?

How can i create HTML report in JMeter using Bean shell sampler in tear down thread?

我想在 JMeter 中的每个测试 运行 之后自动创建一个 HTML 报告,我还想动态创建一个文件夹,以当前时间戳作为文件夹名称,用于将报告放在我的本地驱动器。那么我们如何在拆卸线程组中使用 Bean Shell 采样器来执行此操作?

你的方法不是很好,因为它违反了 2 个主要的 JMeter Best Practices:

  1. 您需要一个 Listener 才能写下结果,使用 Listener 是一个 performance anti-pattern
  2. Since JMeter 3.1 it's recommended to use JSR223 Test Elements and Groovy language 用于脚本

所以我会推荐:

  1. Run your JMeter test in non-GUI mode and generate dashboard after it
  2. 使用您的操作系统 datetime 命令创建时间戳为

    的文件夹
    • Windows 例子:

      jmeter -f -n -t test.jmx -l result.jtl -e -o results-%date:~10,4%-%date:~4,2%-%date:~7,2%
      
    • Linux 示例:

      jmeter -f -n -t test.jmx -l result.jtl -e -o results-`date +%Y-%m-%d`