refactor(接口测试): 优化sql前后置操作放置变量

This commit is contained in:
wxg0103 2024-04-16 10:43:57 +08:00 committed by Craftsman
parent 2aab424c0b
commit 3748463caf
1 changed files with 6 additions and 8 deletions

View File

@ -90,15 +90,13 @@ public abstract class SqlProcessorConverter extends MsProcessorConverter<SQLProc
processor.setProperty(JmeterProperty.SCRIPT_LANGUAGE, ScriptLanguageType.BEANSHELL.name().toLowerCase()); processor.setProperty(JmeterProperty.SCRIPT_LANGUAGE, ScriptLanguageType.BEANSHELL.name().toLowerCase());
StringBuilder scriptBuilder = new StringBuilder(); StringBuilder scriptBuilder = new StringBuilder();
for (KeyValueParam keyValue : extractParams) { extractParams.forEach(keyValue -> {
if (keyValue.isValid()) { String script = """
String script = "vars.put(\"%s\", \"%s\");\n"; vars.put("%s","${%s}");
""";
scriptBuilder.append(String.format(script, keyValue.getKey(), keyValue.getValue())); scriptBuilder.append(String.format(script, keyValue.getKey(), keyValue.getValue()));
} });
}
processor.setProperty(JmeterProperty.SCRIPT, scriptBuilder.toString()); processor.setProperty(JmeterProperty.SCRIPT, scriptBuilder.toString());
return processor; return processor;
} }