fix(场景自动化): 场景下步骤未启用当前场景的环境
This commit is contained in:
parent
809142af53
commit
7a9079a479
|
@ -114,23 +114,26 @@ public class MsScenario extends MsTestElement {
|
|||
// 设置共享cookie
|
||||
config.setEnableCookieShare(enableCookieShare);
|
||||
Map<String, EnvironmentConfig> envConfig = new HashMap<>(16);
|
||||
// 兼容历史数据
|
||||
if (environmentMap == null || environmentMap.isEmpty()) {
|
||||
environmentMap = new HashMap<>(16);
|
||||
if (StringUtils.isNotBlank(environmentId)) {
|
||||
environmentMap.put(SessionUtils.getCurrentProjectId(), environmentId);
|
||||
}
|
||||
}
|
||||
if (environmentMap != null && !environmentMap.isEmpty()) {
|
||||
environmentMap.keySet().forEach(projectId -> {
|
||||
ApiTestEnvironmentService environmentService = CommonBeanFactory.getBean(ApiTestEnvironmentService.class);
|
||||
ApiTestEnvironmentWithBLOBs environment = environmentService.get(environmentMap.get(projectId));
|
||||
if (environment != null && environment.getConfig() != null) {
|
||||
EnvironmentConfig env = JSONObject.parseObject(environment.getConfig(), EnvironmentConfig.class);
|
||||
envConfig.put(projectId, env);
|
||||
if (config.getConfig() == null) {
|
||||
// 兼容历史数据
|
||||
if (this.environmentMap == null || this.environmentMap.isEmpty()) {
|
||||
this.environmentMap = new HashMap<>(16);
|
||||
if (StringUtils.isNotBlank(environmentId)) {
|
||||
// 兼容1.8之前 没有environmentMap但有environmentId的数据
|
||||
this.environmentMap.put("historyProjectID", environmentId);
|
||||
}
|
||||
});
|
||||
config.setConfig(envConfig);
|
||||
}
|
||||
if (this.environmentMap != null && !this.environmentMap.isEmpty()) {
|
||||
this.environmentMap.keySet().forEach(projectId -> {
|
||||
ApiTestEnvironmentService environmentService = CommonBeanFactory.getBean(ApiTestEnvironmentService.class);
|
||||
ApiTestEnvironmentWithBLOBs environment = environmentService.get(this.environmentMap.get(projectId));
|
||||
if (environment != null && environment.getConfig() != null) {
|
||||
EnvironmentConfig env = JSONObject.parseObject(environment.getConfig(), EnvironmentConfig.class);
|
||||
envConfig.put(projectId, env);
|
||||
}
|
||||
});
|
||||
config.setConfig(envConfig);
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(this.getVariables())) {
|
||||
config.setVariables(this.variables);
|
||||
|
|
|
@ -129,6 +129,11 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
config.setConfig(getEnvironmentConfig(useEnvironment));
|
||||
}
|
||||
|
||||
// 1.8 之前历史数据
|
||||
if(StringUtils.isEmpty(this.getProjectId()) && config.getConfig()!= null && !config.getConfig().isEmpty()){
|
||||
this.setProjectId("historyProjectID");
|
||||
}
|
||||
|
||||
// 添加环境中的公共变量
|
||||
Arguments arguments = this.addArguments(config);
|
||||
if (arguments != null) {
|
||||
|
|
|
@ -68,8 +68,8 @@
|
|||
|
||||
let projectId = "";
|
||||
// 如果envMap不存在,是单接口调用
|
||||
if (!this.envMap) {
|
||||
projectId = getCurrentProjectID();
|
||||
if (!this.envMap || this.envMap.size === 0) {
|
||||
projectId = this.$store.state.projectId;
|
||||
} else {
|
||||
// 场景步骤下接口调用
|
||||
projectId = this.runData.projectId;
|
||||
|
|
Loading…
Reference in New Issue