当我尝试从Java代码运行分布式应用程序时,无法生成jtl结果文件
我已使用以下代码在远程服务器上运行测试。
HashTree testPlanTree = new HashTree();
HTTPSamplerProxy examplecomSampler = new HTTPSamplerProxy();
ThreadGroup threadGroup = new ThreadGroup();
threadGroup.setName("Example Thread Group");
threadGroup.setNumThreads(1);
threadGroup.setRampUp(0);
threadGroup.setScheduler(true);
threadGroup.setSamplerController(loopController);
threadGroup.setProperty(TestElement.TEST_CLASS, ThreadGroup.class.getName());
threadGroup.setProperty(TestElement.GUI_CLASS, ThreadGroupGui.class.getName());
threadGroup.setDuration(60);
// Test Plan
TestPlan testPlan = new TestPlan("Create JMeter Script From Java Code");
testPlan.setProperty(TestElement.TEST_CLASS, TestPlan.class.getName());
testPlan.setProperty(TestElement.GUI_CLASS, TestPlanGui.class.getName());
testPlan.setUserDefinedVariables((Arguments) new ArgumentsPanel().createTestElement());
testPlanTree.add(testPlan);
HashTree threadGroupHashTree = testPlanTree.add(testPlan, threadGroup);
HashTree endPointHTTPSampleProxyHashTree = threadGroupHashTree.add(examplecomSampler);
SaveService.saveTree(testPlanTree, new FileOutputStream(jmeterHome + slash + "RemoteTest.jmx"));
Summariser summer = null;
String summariserName = JMeterUtils.getPropDefault("summariser.name", "summary");
if (summariserName.length() > 0) {
summer = new Summariser(summariserName);
}
String logFile = jmeterHome + slash + "RemoteTest.jtl";
ResultCollector logger = new ResultCollector(summer);
logger.setFilename(logFile);
testPlanTree.add(testPlanTree.getArray()[0], logger);
jmeter.configure(testPlanTree);
List<JMeterEngine> engines = new LinkedList<JMeterEngine>();
DistributedRunner distributedRunner=new DistributedRunner();
List<String> hosts = new LinkedList<String>();
hosts.add("Remote_host1");
distributedRunner.setStdout(System.out);
distributedRunner.setStdErr(System.err);
distributedRunner.init(hosts, testPlanTree);
engines.addAll(distributedRunner.getEngines());
distributedRunner.start();
我想在jtl或csv文件中生成结果。