feat(接口测试): 添加场景ID到 JMeter 测试计划变量中

--story=1016499 --user=赵勇 支持通过脚本获取场景的唯一id https://www.tapd.cn/55049933/s/1604337
This commit is contained in:
fit2-zhao 2024-11-01 14:51:37 +08:00 committed by Craftsman
parent d5a61c58ac
commit c0f313de9c
1 changed files with 8 additions and 0 deletions

View File

@ -53,6 +53,14 @@ public class JmeterTestElementParser implements TestElementParser {
this.config = config; this.config = config;
HashTree hashTree = new ListedHashTree(); HashTree hashTree = new ListedHashTree();
TestPlan testPlan = getPlan(); TestPlan testPlan = getPlan();
// 添加场景ID到 JMeter 测试计划变量中
if (msTestElement instanceof MsScenario msScenario) {
Arguments arguments = new Arguments();
arguments.addArgument("ms_scenario_id", msScenario.getResourceId());
testPlan.setUserDefinedVariables(arguments);
}
name = msTestElement.getName(); name = msTestElement.getName();
final HashTree testPlanTree = hashTree.add(testPlan); final HashTree testPlanTree = hashTree.add(testPlan);
final HashTree groupTree = testPlanTree.add(getThreadGroup(msTestElement)); final HashTree groupTree = testPlanTree.add(getThreadGroup(msTestElement));