From 483ed647c8795734e1526c9e6ca33ac860a3fe45 Mon Sep 17 00:00:00 2001 From: zengln Date: Thu, 8 Apr 2021 15:23:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=80=E4=B8=AA=E6=A3=80?= =?UTF-8?q?=E6=9F=A5=E5=8F=98=E9=87=8F=E5=90=8D=E7=9A=84=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Jmeter2Blade/adapter/zxyAdapter.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Jmeter2Blade/adapter/zxyAdapter.py b/Jmeter2Blade/adapter/zxyAdapter.py index 7bee308..c2c11fb 100644 --- a/Jmeter2Blade/adapter/zxyAdapter.py +++ b/Jmeter2Blade/adapter/zxyAdapter.py @@ -53,6 +53,13 @@ def Josn2Blade(message, result, num=0, check_Message=""): return result +# 检查变量名称是否按照blade规则命名 +def check_argument(argument): + if not argument.startswith("varc_"): + argument = "varc_" + argument + return argument + + # 自定义变量组件处理 def deal_arguments(root, node_name): variable_date = VariableData(node_name) @@ -61,11 +68,7 @@ def deal_arguments(root, node_name): var_name = child.find(".//stringProp[@name='Argument.name']") if var_name is not None: - if var_name.text.startswith("varc_"): - data["varName"] = var_name.text - else: - # 将本地变量转成blade格式 - data["varName"] = "varc_" + var_name.text + data["varName"] = check_argument(var_name.text) var_content = child.find(".//stringProp[@name='Argument.value']") if var_content is not None: @@ -251,11 +254,12 @@ def deal_user_parameters(root): names = root.element.findall("collectionProp[@name='UserParameters.names']/stringProp") values = root.element.findall("collectionProp[@name='UserParameters.thread_values']//stringProp") for i in range(len(names)): - params_str += names[i].text + "|" + values[i].text + ";" + params_str += check_argument(names[i].text) + "|" + values[i].text + ";" logger.info(params_str) step.add_presqlcontent(data_sources["default"], params_str) return step.get_step() + # 线程组组件 def deal_threadgroup(root, node_path): # 线程组名称, 作为用例名称