如何在再次执行相同的测试计划时自动清除JMeter中聚合报告表中的结果?

47

执行测试运行后,聚合报告表中将填充刚完成运行的测试计划数据。现在,当我再次执行测试计划时,结果将被添加到聚合报告表中的这些数据中,但我希望在开始显示当前运行结果之前清空表格数据。有什么方法可以做到这一点吗?


你获得了一个可行的答案吗? - BlackGaff
3个回答

74

那没起作用。Ctrl+C是复制命令的快捷键。而且我也没有在“文件”菜单中看到清除它的选项。 - Srikanth
我的错误...应该是CTRL+E。在文件菜单中,它是RUN > CLEAR或RUN > CLEAR ALL。 - BlackGaff
可以了,抱歉回复晚了。其实我很愚蠢,不知道怎么可能错过这么明显的事情。 - Srikanth
你说的“Jmeter没有自动执行此操作的标志”是什么意思?换句话说,这个标志应该放在哪里? - Willa

13

这是一个Beanshell脚本,每次执行它时都会清除结果:

import org.apache.jmeter.gui.GuiPackage;
import org.apache.jmeter.gui.JMeterGUIComponent;
import org.apache.jmeter.gui.tree.JMeterTreeNode;
import org.apache.jmeter.samplers.Clearable;

log.info("Clearing All ...");

guiPackage = GuiPackage.getInstance();

guiPackage.getMainFrame().clearData();
for (JMeterTreeNode node : guiPackage.getTreeModel().getNodesOfType(Clearable.class)) {
    JMeterGUIComponent guiComp = guiPackage.getGui(node.getTestElement());
    if (guiComp instanceof Clearable){
        Clearable item = (Clearable) guiComp;
        try {
            item.clearData();
        } catch (Exception ex) {
            log.error("Can't clear: "+node+" "+guiComp, ex);
        }
    }
}

要在您的JMeter脚本中使用此Beanshell脚本:

1) Select the root node of your JMeter Script, and, using the mouse menu, add a setup node :

   Add / Threads (Users) / setup Thread Group

2) Select the newly created node, and using the mouse menu, add a script node :

   Add / Samplers / Beanshell Sampler

3) Finally, copy and paste the above script into the Script window.


1
这个非常有用的BeanShell脚本会失败,如果Jmeter在无头模式下运行,因为GUI组件不存在。然而,如果你将这个BeanShell包装在一个If控制器中,你可以检查一个只存在于命令行的变量,然后你可以在测试中保留脚本,无论是GUI还是无头模式。 - Aidan

4

注意:下面给出了通过 GUI 功能手动实现此操作的步骤。

Clear 选项可在 Run 菜单下找到。

功能 Windows 键盘快捷键 macOS 键盘快捷键
清除 CTRL+SHIFT+E +SHIFT+E
全部清除 CTRL+E +E

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接