fix(接口测试): 脚本步骤结果没有步骤ID

This commit is contained in:
AgAngle 2024-04-01 17:41:56 +08:00 committed by 刘瑞斌
parent 90da30e833
commit 2441a882cc
3 changed files with 20 additions and 16 deletions

View File

@ -1,8 +1,10 @@
package io.metersphere.plugin.api.spi;
import io.metersphere.plugin.api.constants.ElementProperty;
import io.metersphere.plugin.api.dto.ParameterConfig;
import lombok.Setter;
import org.apache.jmeter.testelement.TestElement;
import org.apache.jorphan.collections.HashTree;
import java.lang.reflect.ParameterizedType;
@ -49,4 +51,19 @@ public abstract class AbstractJmeterElementConverter<T extends MsTestElement> im
});
}
}
/**
* 设置步骤标识
* 当前步骤唯一标识结果和步骤匹配的关键
*
* @param msHTTPElement
* @param config
* @param sampler
*/
public void setStepIdentification(AbstractMsTestElement msHTTPElement, ParameterConfig config, TestElement sampler) {
sampler.setProperty(ElementProperty.MS_RESOURCE_ID.name(), msHTTPElement.getResourceId());
sampler.setProperty(ElementProperty.MS_STEP_ID.name(), msHTTPElement.getStepId());
sampler.setProperty(ElementProperty.MS_REPORT_ID.name(), config.getReportId());
sampler.setProperty(ElementProperty.PROJECT_ID.name(), msHTTPElement.getProjectId());
}
}

View File

@ -13,7 +13,6 @@ import io.metersphere.api.parser.jmeter.body.MsBodyConverterFactory;
import io.metersphere.api.parser.jmeter.body.MsFormDataBodyConverter;
import io.metersphere.api.parser.jmeter.body.MsWWWFormBodyConverter;
import io.metersphere.jmeter.mock.Mock;
import io.metersphere.plugin.api.constants.ElementProperty;
import io.metersphere.plugin.api.dto.ParameterConfig;
import io.metersphere.plugin.api.spi.AbstractJmeterElementConverter;
import io.metersphere.project.api.KeyValueEnableParam;
@ -201,21 +200,6 @@ public class MsHTTPElementConverter extends AbstractJmeterElementConverter<MsHTT
return JmeterTestElementParserHelper.getArguments(msHTTPElement.getName(), envVariables);
}
/**
* 设置步骤标识
* 当前步骤唯一标识结果和步骤匹配的关键
*
* @param msHTTPElement
* @param config
* @param sampler
*/
private void setStepIdentification(MsHTTPElement msHTTPElement, ParameterConfig config, HTTPSamplerProxy sampler) {
sampler.setProperty(ElementProperty.MS_RESOURCE_ID.name(), msHTTPElement.getResourceId());
sampler.setProperty(ElementProperty.MS_STEP_ID.name(), msHTTPElement.getStepId());
sampler.setProperty(ElementProperty.MS_REPORT_ID.name(), config.getReportId());
sampler.setProperty(ElementProperty.PROJECT_ID.name(), msHTTPElement.getProjectId());
}
private String getPath(MsHTTPElement msHTTPElement, HttpConfig httpConfig) {
String url = msHTTPElement.getPath();
if (httpConfig != null) {

View File

@ -29,6 +29,9 @@ public class MsScriptElementConverter extends AbstractJmeterElementConverter<MsS
scriptElement = new BeanShellSampler();
}
ScriptProcessorConverter.parse(scriptElement, scriptProcessor, config);
setStepIdentification(msScriptElement, config, scriptElement);
hashTree.add(scriptElement);
}
}