Search code examples
xmllinuxjmeterjmxjmeter-plugins

How to not append the old Result.xml file in Jmeter?


In Jmeter in linux, I am creating Result.xml for each test suite on re-running it gets appended to the old Result.xml but i want to create a new Result.xml

For this i need to run rm -rf Result.xml before the test plan execution.

I used OS Process Sampler for this in Jmeter as follows :

3 OS Process Samplers

First I need to go to the folder where Result.xml and Jmeter.jmx files are there. But this path is not fixed.

So I have used pushd . to save the current path from which Jmeter.jmx file will be run in non-gui mode(same directory where Result.xml will be present).

Then popd to go to this path which should be the folder where Jmeter.jmx and Result.xml file is there.

And then remove rm -rf Result.xml which should remove Result.xml file.

Then execute the rest of the calls and make a new Result.xml file in the same directory.

Execution sequence of the entire suite


This method is not working properly as, the result of the test execution doesnt give any error but there is no new Result.xml created. Which means that even if OS Process Sampler are placed before the test suite, it deletes new Result.xml file. Hence, before Results Tree is created or executed, Result.xml is made.

How can i run OS Process Sampler to remove the old Result.xml file?


Solution

  • The reason is that you cannot remove the file which is being opened by JMeter for writing the results. However you can clean the contents of the file using a single OS Process Sampler configured like:

    JMeter OS Process Sampler configuration


    In general your approach is not very good as using XML output format and having listeners enabled during the test run violates JMeter Best Practices as listeners cause massive IO overhead so I would recommend reconsidering your results saving approach and using -l command-line argument to specify results file location instead of using the listeners.