2016-01-18 25 views
0

我試着運行下面的代碼在eclipse中發佈了here無法從Java代碼運行Jmeter

但它沒有得到執行。它引發以下錯誤:

NOTE: I also added external jars from jmeter installation file from lib/ext

代碼:

public class JMeterFromScratch { 

    public static void main(String[] args){ 
     // Engine 
     StandardJMeterEngine jm = new StandardJMeterEngine(); 
     JMeterUtils.loadJMeterProperties("//Users//z001rdr//Documents//workspace//PerfTest//src//test//jmeter/jmeter.properties"); 

     HashTree hashTree = new HashTree();  

     // HTTP Sampler 
     HTTPSampler httpSampler = new HTTPSampler(); 
     httpSampler.setDomain("www.google.com"); 
     httpSampler.setPort(80); 
     httpSampler.setPath("/"); 
     httpSampler.setMethod("GET"); 

     // Loop Controller 
     TestElement loopCtrl = new LoopController(); 
     ((LoopController)loopCtrl).setLoops(1); 
     ((LoopController)loopCtrl).addTestElement(httpSampler); 
     ((LoopController)loopCtrl).setFirst(true); 

     // Thread Group 
     SetupThreadGroup threadGroup = new SetupThreadGroup(); 
     threadGroup.setNumThreads(1); 
     threadGroup.setRampUp(1); 
     threadGroup.setSamplerController((LoopController)loopCtrl); 

     // Test plan 
     TestPlan testPlan = new TestPlan("MY TEST PLAN"); 

     hashTree.add("testPlan", testPlan); 
     hashTree.add("loopCtrl", loopCtrl); 
     hashTree.add("threadGroup", threadGroup); 
     hashTree.add("httpSampler", httpSampler);  

     jm.configure(hashTree); 

     Summariser summer = null; 
     String summariserName = JMeterUtils.getPropDefault("summariser.name", "summary");//$NON-NLS-1$ 
     if (summariserName.length() > 0) { 
      summer = new Summariser(summariserName); 
     } 

     String logFile = "/path/to/output/file.jtl"; 
     ResultCollector logger = new ResultCollector(summer); 
     logger.setFilename(logFile); 
     hashTree.add(hashTree.getArray()[0], logger); 
     jm.run(); 
    } 
} 
+0

日誌文件:2016年1月18日DEBUG 13:07:[。jorphan] 31.509():沒有找到:/用戶/ z001rdr /。 m2/repository/excalibur-instrument/excalibur-instrument/1.0/excalibur-instrument-1.0.jar DEBUG 2016-01-18 13:07:31.509 [jorphan。]():未找到:/ Users/z001rdr /。 m2/repository/excalibur-logger/excalibur-logger/1.1/excalibur-logger-1.1.jar DEBUG 2016-01-18 13:07:31.509 [jorphan。]():未找到:/ Users/z001rdr /。 m2/repository/excalibur-pool/excalibur-pool/1.2/excalibur-pool-1.2.jar – jmeter

+0

請直接將您的評論中的信息添加到您的問題中。 – RaGe

+0

也看起來像你沒有找到所需的依賴關係的問題,而不是與JMeter本身。確保你的pom.xml中的所有必需的依賴和配置正確。 – RaGe

回答