执行测试运行后,聚合报告表中将填充刚完成运行的测试计划数据。现在,当我再次执行测试计划时,结果将被添加到聚合报告表中的这些数据中,但我希望在开始显示当前运行结果之前清空表格数据。有什么方法可以做到这一点吗?
执行测试运行后,聚合报告表中将填充刚完成运行的测试计划数据。现在,当我再次执行测试计划时,结果将被添加到聚合报告表中的这些数据中,但我希望在开始显示当前运行结果之前清空表格数据。有什么方法可以做到这一点吗?
Jmeter没有自动执行此操作的标志。
通常情况下,您需要使用CTRL+E(在Windows中)或从文件菜单中选择RUN > CLEAR或RUN > CLEAR ALL清除结果。
您可以尝试编写一个Beanshell脚本,以便每次执行脚本时都清除结果。
http://www.javadocexamples.com/java_examples/org/apache/jmeter/samplers/SampleListener/
这是一个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.
注意:下面给出了通过 GUI 功能手动实现此操作的步骤。
Clear
选项可在 Run
菜单下找到。
功能 | Windows 键盘快捷键 | macOS 键盘快捷键 |
---|---|---|
清除 | CTRL+SHIFT+E | ⌘+SHIFT+E |
全部清除 | CTRL+E | ⌘+E |