refactor(接口测试): 优化接口字段

This commit is contained in:
AgAngle 2023-12-22 16:58:01 +08:00 committed by Craftsman
parent 65e9c45897
commit d20f596363
5 changed files with 35 additions and 10 deletions

View File

@ -15,11 +15,25 @@ import java.util.LinkedList;
@JsonIgnoreProperties(ignoreUnknown = true)
public abstract class AbstractMsTestElement implements MsTestElement {
// 组件标签名称
/**
* 步骤ID唯一
*/
private String stepId;
/**
* 关联的资源ID用例ID/接口ID/场景ID)
*/
private String resourceId;
/**
* 组件标签名称
*/
private String name;
// 是否启用
private Boolean enable = true;
// 子组件
/**
* 是否启用
*/
private Boolean enable = true;
/**
* 子组件
*/
private LinkedList<AbstractMsTestElement> children;
}

View File

@ -9,10 +9,6 @@ import org.apache.commons.lang3.StringUtils;
*/
@Data
public class KeyValueParam {
/**
* 参数ID
*/
private String id;
/**
*
*/

View File

@ -9,6 +9,8 @@ import io.metersphere.api.parser.jmeter.body.MsFormDataBodyConverter;
import io.metersphere.api.parser.jmeter.body.MsWWWFormBodyConverter;
import io.metersphere.plugin.api.dto.ParameterConfig;
import io.metersphere.plugin.api.spi.AbstractJmeterElementConverter;
import io.metersphere.sdk.util.LogUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy;
import org.apache.jmeter.save.SaveService;
@ -28,6 +30,10 @@ public class MsHTTPElementConverter extends AbstractJmeterElementConverter<MsHTT
@Override
public void toHashTree(HashTree tree, MsHTTPElement msHTTPElement, ParameterConfig config) {
if (BooleanUtils.isFalse(msHTTPElement.getEnable())) {
LogUtils.info("MsHTTPElement is disabled");
return;
}
this.config = config;
HTTPSamplerProxy sampler = new HTTPSamplerProxy();
sampler.setName(msHTTPElement.getName());

View File

@ -416,6 +416,7 @@ public class ApiDebugControllerTests extends BaseTest {
Body generalBody = MsHTTPElementTest.getGeneralBody();
generalBody.setBodyType(Body.BodyType.FORM_DATA.name());
msHTTPElement.setBody(generalBody);
msHTTPElement.setEnable(true);
request.setRequest(ApiDataUtils.toJSONString(msHTTPElement));
this.requestPostWithOk(DEBUG, request);
@ -439,11 +440,19 @@ public class ApiDebugControllerTests extends BaseTest {
request.setRequest(ApiDataUtils.toJSONString(msHTTPElement));
this.requestPostWithOk(DEBUG, request);
// 测试 XML
// 测试 RAW
generalBody.setBodyType(Body.BodyType.RAW.name());
request.setRequest(ApiDataUtils.toJSONString(msHTTPElement));
this.requestPostWithOk(DEBUG, request);
// 增加覆盖率
msHTTPElement.setMethod("GET");
request.setRequest(ApiDataUtils.toJSONString(msHTTPElement));
this.requestPostWithOk(DEBUG, request);
msHTTPElement.setEnable(false);
request.setRequest(ApiDataUtils.toJSONString(msHTTPElement));
this.requestPostWithOk(DEBUG, request);
// 增加覆盖率
new TestElementParserFactory();
new ImportParserFactory();

View File

@ -202,7 +202,7 @@ public class PluginLoadService {
/**
* 卸载插件
*/
public void unloadPlugin(String pluginId) {
public synchronized void unloadPlugin(String pluginId) {
if (hasPlugin(pluginId)) {
msPluginManager.deletePlugin(pluginId);
}