1
votes

I am creating a java class which will start the Jmeter Engine and run the JMX file and give me Result in .jtl file. But the given .jtl file provides me only the below datas

timeStamp,elapsed,label,responseCode,responseMessage,threadName,dataType,success,failureMessage,bytes,sentBytes,grpThreads,allThreads,IdleTime,Connect 1514980442998,2688,test,200,OK,test 1-1,text,true,,136171,125,1,1,0,1561

But I want Avg ,max ,min , error % also. These are provided by the Summariser class but only in console but i want the same appended into my .jtl file.

Below is my class

 public class ResultExtractor {


    public static void main(String[] args) {



        StandardJMeterEngine jmeter = new StandardJMeterEngine();

        System.out.println("::>>>>>>>>>>>>JMETER engine intialized");
        JMeterUtils.loadJMeterProperties("./jmeter_project_data/apache-jmeter-3.3/bin/jmeter.properties");
        JMeterUtils.setJMeterHome("./jmeter_project_data/apache-jmeter-3.3");
        JMeterUtils.initLogging();
        JMeterUtils.initLocale();
        try {
            SaveService.loadProperties();

        } catch (IOException e) {
            e.printStackTrace();
        }

        File in=new File("./jmeter_project_data/JMXtestdata/test.jmx");
        System.out.println("::>>>>>>>>>>>>JMX file is passed");     
        HashTree testPlanTree =null;
        try {
         testPlanTree = SaveService.loadTree(in);
            } 
        catch (IOException e) 
            {
         e.printStackTrace();
            }
        jmeter.configure(testPlanTree);
        System.out.println("::>>>>>>>>>>>>Confgurd test in jmeter");
        Summariser summer = null;
        String summariserName = JMeterUtils.getPropDefault("summariser.name", "summary");//$NON-NLS-1$
        if (summariserName.length() > 0) {
            summer = new Summariser(summariserName);
        }

        String logFile = "./jmeter_project_data/Result/jmeterresult.jtl";
        ResultCollector logger = new ResultCollector(summer);
        logger.setFilename(logFile);
        testPlanTree.add(testPlanTree.getArray()[0], logger);

        System.out.println("::>>>>>>>>>>>> Test Started");
        jmeter.run();
        System.out.println("::>>>>>>>>>>>> Test Finished");

    }

}

Please help me to get the data in the jtl file.

1

1 Answers

0
votes

I would not recommend adding anything to .jtl results file as it assumes certain structure and if you append something "alien" you won't be able either to analyse it using Listeners or generate HTML Reporting Dashboard.

I would recommend configuring JMeter to store Summariser output to jmeter.log file instead, it is controllable via the following JMeter property:

summariser.log=true

as well you can control how often it will print messages to STDOUT/jmeter.log file:

summariser.interval=30

More information: Top 2 Techniques to Get JMeter Test Results in non-GUI mode