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());
StringBuilder scriptBuilder = new StringBuilder();
for (KeyValueParam keyValue : extractParams) {
if (keyValue.isValid()) {
String script = "vars.put(\"%s\", \"%s\");\n";
scriptBuilder.append(String.format(script, keyValue.getKey(), keyValue.getValue()));
}
}
extractParams.forEach(keyValue -> {
String script = """
vars.put("%s","${%s}");
""";
scriptBuilder.append(String.format(script, keyValue.getKey(), keyValue.getValue()));
});
processor.setProperty(JmeterProperty.SCRIPT, scriptBuilder.toString());
return processor;
}