SHARE
TWEET

Untitled

a guest Aug 14th, 2019 46 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import org.apache.jmeter.engine.StandardJMeterEngine;
  2. import org.apache.jmeter.reporters.ResultCollector;
  3. import org.apache.jmeter.reporters.Summariser;
  4. import org.apache.jmeter.save.SaveService;
  5. import org.apache.jmeter.util.JMeterUtils;
  6. import org.apache.jorphan.collections.HashTree;
  7.  
  8. import java.io.File;
  9.  
  10. public class ExistingTest {
  11.  
  12.     public static void main(String[] args) throws Exception {
  13.         StandardJMeterEngine jmeter = new StandardJMeterEngine();
  14.  
  15.         JMeterUtils.loadJMeterProperties("/path/to/your/jmeter/bin/jmeter.properties");
  16.         JMeterUtils.setJMeterHome("/path/to/your/jmeter");
  17.         JMeterUtils.initLocale();
  18.  
  19.         SaveService.loadProperties();
  20.  
  21.         HashTree testPlanTree = SaveService.loadTree(new File("/path/to/your/jmeter/extras/Test.jmx"));
  22.  
  23.         Summariser summer = null;
  24.         String summariserName = JMeterUtils.getPropDefault("summariser.name", "summary");
  25.         if (summariserName.length() > 0) {
  26.             summer = new Summariser(summariserName);
  27.         }
  28.  
  29.         String resultFile = "/path/to/test/result.jtl";
  30.         ResultCollector logger = new ResultCollector(summer);
  31.         logger.setFilename(resultFile);
  32.         testPlanTree.add(testPlanTree.getArray()[0], logger);
  33.  
  34.         jmeter.configure(testPlanTree);
  35.         jmeter.run();
  36.     }
  37. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top