fix(接口测试): 引用的公共脚本,无法设置环境变量
--bug=1045905 --user=陈建星 【接口测试】github#32861,公共脚本处设置环境参数,在用例前置里引用报错。 https://www.tapd.cn/55049933/s/1578918
This commit is contained in:
parent
bfaa4994d8
commit
a885cbefd5
|
@ -38,16 +38,6 @@ public abstract class ScriptProcessorConverter extends MsProcessorConverter<Scri
|
||||||
String name = StringUtils.isEmpty(scriptProcessor.getName()) ? scriptProcessor.getClass().getSimpleName() : scriptProcessor.getName();
|
String name = StringUtils.isEmpty(scriptProcessor.getName()) ? scriptProcessor.getClass().getSimpleName() : scriptProcessor.getName();
|
||||||
testElement.setName(name);
|
testElement.setName(name);
|
||||||
|
|
||||||
// 设置环境变量
|
|
||||||
ApiParamConfig apiParamConfig = (ApiParamConfig) config;
|
|
||||||
EnvironmentInfoDTO envConfig = apiParamConfig.getEnvConfig(scriptProcessor.getProjectId());
|
|
||||||
if (envConfig != null) {
|
|
||||||
String envId = envConfig.getId();
|
|
||||||
if (StringUtils.isNotEmpty(scriptProcessor.getScript())) {
|
|
||||||
scriptProcessor.setScript(StringUtils.replace(scriptProcessor.getScript(), ENV_VARIABLE_EXPRESSION, "\"" + MS_RUNNING_ENV_PREFIX + envId + ".\""));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// python 和 js cache 打开
|
// python 和 js cache 打开
|
||||||
boolean cacheKey = StringUtils.equalsAny(scriptProcessor.getScriptLanguage(), ScriptLanguageType.PYTHON.name(), ScriptLanguageType.JAVASCRIPT.name());
|
boolean cacheKey = StringUtils.equalsAny(scriptProcessor.getScriptLanguage(), ScriptLanguageType.PYTHON.name(), ScriptLanguageType.JAVASCRIPT.name());
|
||||||
testElement.setProperty(JmeterProperty.CACHE_KEY, cacheKey);
|
testElement.setProperty(JmeterProperty.CACHE_KEY, cacheKey);
|
||||||
|
@ -64,6 +54,17 @@ public abstract class ScriptProcessorConverter extends MsProcessorConverter<Scri
|
||||||
scriptLanguage = scriptProcessor.getCommonScriptInfo().getScriptLanguage();
|
scriptLanguage = scriptProcessor.getCommonScriptInfo().getScriptLanguage();
|
||||||
script = scriptProcessor.getCommonScriptInfo().getScript();
|
script = scriptProcessor.getCommonScriptInfo().getScript();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 设置环境变量
|
||||||
|
ApiParamConfig apiParamConfig = (ApiParamConfig) config;
|
||||||
|
EnvironmentInfoDTO envConfig = apiParamConfig.getEnvConfig(scriptProcessor.getProjectId());
|
||||||
|
if (envConfig != null) {
|
||||||
|
String envId = envConfig.getId();
|
||||||
|
if (StringUtils.isNotEmpty(script)) {
|
||||||
|
script = StringUtils.replace(script, ENV_VARIABLE_EXPRESSION, "\"" + MS_RUNNING_ENV_PREFIX + envId + ".\"");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (scriptLanguage == null || StringUtils.equalsIgnoreCase(scriptLanguage, ScriptLanguageType.BEANSHELL_JSR233.name())) {
|
if (scriptLanguage == null || StringUtils.equalsIgnoreCase(scriptLanguage, ScriptLanguageType.BEANSHELL_JSR233.name())) {
|
||||||
scriptLanguage = ScriptLanguageType.BEANSHELL.name();
|
scriptLanguage = ScriptLanguageType.BEANSHELL.name();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue