fix(接口测试): 修复场景导入非标准JMX文件失败问题

--bug=1027337 --user=王孝刚 【接口测试】接口自动化中导入jmeter文件失败
https://www.tapd.cn/55049933/s/1386032
This commit is contained in:
wxg0103 2023-06-26 10:52:17 +08:00 committed by 刘瑞斌
parent d8549c278e
commit bbc8641165
1 changed files with 23 additions and 20 deletions

View File

@ -106,7 +106,7 @@ public class JMeterParser extends ApiImportAbstractParser<ScenarioImport> {
MsScenario scenario = new MsScenario(); MsScenario scenario = new MsScenario();
scenario.setReferenced("IMPORT"); scenario.setReferenced("IMPORT");
if (testPlan.getArray()[0] instanceof TestPlan) {
TestPlan plan = (TestPlan) testPlan.getArray()[0]; TestPlan plan = (TestPlan) testPlan.getArray()[0];
if (plan.getArguments() != null) { if (plan.getArguments() != null) {
List<ScenarioVariable> variables = new LinkedList<>(); List<ScenarioVariable> variables = new LinkedList<>();
@ -127,6 +127,9 @@ public class JMeterParser extends ApiImportAbstractParser<ScenarioImport> {
scenario.setHashTree(new LinkedList<>()); scenario.setHashTree(new LinkedList<>());
} }
formatHashTree(testPlan.getTree(plan), scenario); formatHashTree(testPlan.getTree(plan), scenario);
} else {
formatHashTree(testPlan, scenario);
}
this.projectId = request.getProjectId(); this.projectId = request.getProjectId();
ScenarioImport scenarioImport = new ScenarioImport(); ScenarioImport scenarioImport = new ScenarioImport();
scenarioImport.setData(parseObj(scenario, request)); scenarioImport.setData(parseObj(scenario, request));