fix(接口测试): 接口执行脚本没有设置项目参数
This commit is contained in:
parent
c97d58629c
commit
5ceccd1a77
|
@ -1,5 +1,5 @@
|
|||
package io.metersphere.plugin.api.constants;
|
||||
|
||||
public enum ElementProperty {
|
||||
MS_RESOURCE_ID, MS_STEP_ID, MS_FAKE_ERROR, MS_REPORT_ID, PROJECT_ID,SCENARIO_CONSTANT_TIMER
|
||||
MS_RESOURCE_ID, MS_STEP_ID, MS_FAKE_ERROR, MS_REPORT_ID, PROJECT_ID, SCENARIO_CONSTANT_TIMER
|
||||
}
|
||||
|
|
|
@ -42,6 +42,11 @@ public class ApiScenarioScheduleJob extends BaseScheduleJob {
|
|||
parseParam.setEnvironmentId(apiRunModeConfigDTO.getEnvironmentId());
|
||||
parseParam.setGrouped(apiRunModeConfigDTO.getGrouped());
|
||||
|
||||
if (StringUtils.isBlank(apiRunModeConfigDTO.getEnvironmentId())) {
|
||||
parseParam.setEnvironmentId(apiScenarioDetail.getEnvironmentId());
|
||||
parseParam.setGrouped(apiScenarioDetail.getGrouped());
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(apiRunModeConfigDTO.getPoolId())) {
|
||||
apiRunModeConfigDTO.setPoolId(apiExecuteService.getProjectApiResourcePoolId(apiScenarioDetail.getProjectId()));
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ public class MsCommonElementConverter extends AbstractJmeterElementConverter<MsC
|
|||
|
||||
@Override
|
||||
public void toHashTree(HashTree tree, MsCommonElement element, ParameterConfig config) {
|
||||
element.setProjectId(element.getParent().getProjectId());
|
||||
EnvironmentInfoDTO envInfo = getEnvInfo(element, config);
|
||||
// 解析前置处理器,包括环境前置
|
||||
addProcessors(tree, element, config, envInfo, true);
|
||||
|
@ -78,7 +79,10 @@ public class MsCommonElementConverter extends AbstractJmeterElementConverter<MsC
|
|||
}
|
||||
|
||||
assertionConfig.getAssertions()
|
||||
.forEach(assertion -> AssertionConverterFactory.getConverter(assertion.getClass()).parse(tree, assertion, config, isIgnoreAssertStatus(assertions)));
|
||||
.forEach(assertion -> {
|
||||
assertion.setProjectId(element.getProjectId());
|
||||
AssertionConverterFactory.getConverter(assertion.getClass()).parse(tree, assertion, config, isIgnoreAssertStatus(assertions));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -255,6 +255,7 @@ public class ApiExecuteService {
|
|||
MsScriptElement msScriptElement = new MsScriptElement();
|
||||
msScriptElement.setEnableCommonScript(true);
|
||||
msScriptElement.setName(runRequest.getReportId());
|
||||
msScriptElement.setProjectId(runRequest.getProjectId());
|
||||
CommonScriptInfo commonScriptInfo = new CommonScriptInfo();
|
||||
commonScriptInfo.setId(runRequest.getProjectId());
|
||||
commonScriptInfo.setParams(runRequest.getParams());
|
||||
|
|
|
@ -2098,6 +2098,11 @@ public class ApiScenarioService extends MoveNodeService {
|
|||
if (isRefOrPartialScenario(step)) {
|
||||
|
||||
List<ApiScenarioStepDTO> scenarioSteps = scenarioStepMap.get(step.getResourceId());
|
||||
|
||||
if (CollectionUtils.isEmpty(scenarioSteps)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
scenarioSteps.forEach(item -> {
|
||||
// 如果步骤的场景ID不等于当前场景的ID,说明是引用的步骤,如果 parentId 为空,说明是一级子步骤,重新挂载到对应的场景中
|
||||
if (StringUtils.isEmpty(item.getParentId())) {
|
||||
|
|
|
@ -43,4 +43,9 @@ public abstract class MsAssertion {
|
|||
* id
|
||||
*/
|
||||
private String id;
|
||||
/**
|
||||
* 项目ID
|
||||
* 执行时设置
|
||||
*/
|
||||
private String projectId;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue