java测试计划结构在JMeter UI(预期)和API(错误)之间变化
我的测试计划在UI中是这样的
Test Plan
Thread Group1
Sampler 1
header manager
result collector
bean shell post processor
Sampler 2
bean shell pre processor
header manager
result collector
bean shell post processor
Thread Group2
Bean shell pre processor
Throughput 1
Sampler 3
header manager
result collector
Throughput 2
Sampler 4
bean shell pre processor
header manager
result collector
bean shell post processor
Sampler 5
header manager
result collector
Result Collector
在Java代码中,我尝试像这样添加采样器
ThroughputController throughput1 = new ThroughputController();
throughput1.setPercentThroughput(100.0f);
ThroughputController throughput2 = new ThroughputController();
throughput1.setPercentThroughput(0.0f);
TestPlan testPlan = new TestPlan();
testPlan.setSerialized(true);
HashTree throughputTree1 = new HashTree();
HashTree throughputTree2 = new HashTree();
HashTree testPlanTree = new HashTree();
HashTree threadGroupTree1 = new HashTree();
HashTree samplerTree1 = new HashTree();
samplerTree1.add(sampler1,resultCollector1);
samplerTree1.add(sampler1,header1);
但输出测试计划树并不像预期的那样
我怎样才能像在UI中一样,按照上面提到的顺序获得测试计划
二,。测试计划树会随着Java版本的不同而变化吗
# 1 楼答案
以下代码依赖于JMeter API:
产生JMeter Test Plan类似:
这应该是你要找的东西
还要注意,有一种更简单的方法可以在不使用JMeter GUI的情况下创建JMeter测试计划,Taurus工具提供了使用简单的YAML语法创建和运行JMeter测试的可能性,有关详细信息,请参阅Taurus: A New Star in the Test Automation Tools Constellation文章