【发布时间】:2013-10-09 10:41:46
【问题描述】:
我想使用 Apache JMeter 提供的 API 从 Java 程序创建和运行测试脚本。我已经了解了 ThreadGroup 和 Samplers 的基础知识。我可以使用 JMeter API 在我的 Java 类中创建它们。
ThreadGroup threadGroup = new ThreadGroup();
LoopController lc = new LoopController();
lc.setLoops(5);
lc.setContinueForever(true);
threadGroup.setSamplerController(lc);
threadGroup.setNumThreads(5);
threadGroup.setRampUp(1);
HTTPSampler sampler = new HTTPSampler();
sampler.setDomain("localhost");
sampler.setPort(8080);
sampler.setPath("/jpetstore/shop/viewCategory.shtml");
sampler.setMethod("GET");
Arguments arg = new Arguments();
arg.addArgument("categoryId", "FISH");
sampler.setArguments(arg);
但是,我不知道如何创建一个结合线程组和采样器的测试脚本,然后从同一个程序中执行它。有任何想法吗?
【问题讨论】:
标签: java api automated-tests jmeter