如何加上「;随请求发送参数";在jmeter中使用java
我是jmeter新手,我想使用java代码以非gui方式执行jmeter 在端点上进行测试时,我希望通过java代码传递“随请求发送参数”。因此,我已尝试按如下方式发送数据如何加上「;随请求发送参数";在jmeter中使用java,jmeter,Jmeter,我是jmeter新手,我想使用java代码以非gui方式执行jmeter 在端点上进行测试时,我希望通过java代码传递“随请求发送参数”。因此,我已尝试按如下方式发送数据 HTTPSampler httpSampler = new HTTPSampler(); httpSampler.setProtocol("http"); httpSampler.setDomain(hostip); httpSampler.setPort(80
HTTPSampler httpSampler = new HTTPSampler();
httpSampler.setProtocol("http");
httpSampler.setDomain(hostip);
httpSampler.setPort(8080);
httpSampler.setPath(endpointpath);
httpSampler.setMethod("POST");
HTTPArgument httpArgument = new HTTPArgument();
httpArgument.setValue("[{ \"firstname\": "", \"name\": \"Venkat\"}]");
没有出现错误。请求未添加到数据库中
有人能建议并提供一个示例代码来使用java添加post请求主体吗?httpSampler没有相关的参数。基本上,您只是发送一个http请求,没有任何参数 您可能必须使用addTestElement/setArgument方法将参数与httpsampler关联
httpSampler.setMethod("POST");
HTTPArgument httpArgument = new HTTPArgument();
httpArgument.setValue("[{ \"firstname\": \"venkatachalam\", \"name\": \"Venkata\"}]");
httpSampler.addTestElement(httpArgument);
只是好奇——顺便问一下,为什么要使用java创建JMeter测试
要在非gui模式下运行JMeter测试,请使用以下命令和选项。(假设已将%JMETER_HOME%/bin添加到PATH变量)
- -n[这指定JMeter在非gui模式下运行]
- -t[包含测试计划的JMX文件的名称]
- -l[记录样本结果的JTL文件的名称]
- -j[JMeter运行日志文件的名称]
- -R[远程服务器列表]在指定的远程服务器中运行测试
- -H[代理服务器主机名或ip地址] -P[代理服务器端口]
jmeter -n -t D:\TestScripts\script.jmx -l D:\TestScripts\scriptresults.jtl