简体   繁体   中英

Build Jmeter JMX file using JAVA for parallel load with different set of data

I'm trying to build the JMX file for JMETER through Java to keep in inline with my service automation framework. Ultimately i do not want to use JMETER UI to avoid rework on the request generation. Partially i have succeeded in the same but the problem is i'm not able to create a JMX file which can work with multiple input.

Generally, this is achieved in JMETER UI by using CSV data set config. Can someone help me in achieving the parallel request load with varying data from CSV using JAVA ?

Please find below the sampler code that i'm using now.

examplecomSampler.setName("Test");
examplecomSampler.setDomain("SampleDomain");
examplecomSampler.setPort("Sample Port");
examplecomSampler.setPath("Sample Path");
examplecomSampler.setMethod("Test");
examplecomSampler.setProtocol("https");
examplecomSampler.addNonEncodedArgument("",strJson , "");
examplecomSampler.setProperty(TestElement.TEST_CLASS, HTTPSamplerProxy.class.getName());
examplecomSampler.setProperty(TestElement.GUI_CLASS, HttpTestSampleGui.class.getName());

Yes we can help you to achieve this in JMETER with JAVA .

CSV DATA SET CONFIG can be ADDED just the SAME way you did with HTTP REQUEST sampler

The relevant CLASS is CSVDataSet . If you need an EXAMPLE in JAVA here is SOME reference CODE

CSVDataSet csvDataSet = new CSVDataSet();
csvDataSet.setName("CSV Data Set Config");
csvDataSet.setProperty("delimiter",",");
csvDataSet.setProperty("filename","/path/to/your/file.csv");
csvDataSet.setProperty("fileEncoding","UTF-8");
csvDataSet.setProperty("ignoreFirstLine",false);
csvDataSet.setProperty("quotedData",false);
csvDataSet.setProperty("recycle",true);
csvDataSet.setProperty("shareMode","shareMode.all");
csvDataSet.setProperty("stopThread",false);
csvDataSet.setProperty("variableNames","your_variable_name");
csvDataSet.setProperty(TestElement.TEST_CLASS,CSVDataSet.class.getName());
csvDataSet.setProperty(TestElement.GUI_CLASS,TestBeanGUI.class.getName());

More information: Five Ways To Launch a JMeter Test without Using the JMeter GUI

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM