How to clear the results in Aggregate Report's table in JMeter automatically when executing the same test plan again?
Jmeter does not have a flag to do this automatically.
Generally, you have to clear the results with CTRL+E (in windows) or from the file menu, under RUN > CLEAR or RUN > CLEAR ALL
You might be able to write a beanshell script to clear the results everytime you execute the script.
http://www.javadocexamples.com/java_examples/org/apache/jmeter/samplers/SampleListener/
Here is a Beanshell script that will clear the results everytime you execute it:
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);
}
}
}
To use this Beanshell script in your JMeter Script :
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.
Note: Manual procedure to achieve this via GUI functions is given below.
The Clear
option is available under the Run
menu.
Function | Windows Keyboard Shortcut | macOS Keyboard Shortcut |
---|---|---|
Clear | CTRL+SHIFT+E | ⌘+SHIFT+E |
Clear All | CTRL+E | ⌘+E |