feat(接口测试): 添加mock函数预览

This commit is contained in:
fit2-zhao 2023-11-23 17:49:48 +08:00 committed by Craftsman
parent af3ef24316
commit 864b9124ac
3 changed files with 16 additions and 1 deletions

View File

@ -1,6 +1,7 @@
package io.metersphere.api.controller;
import io.metersphere.api.service.ApiTestService;
import io.metersphere.jmeter.mock.Mock;
import io.metersphere.system.dto.ProtocolDTO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
@ -29,4 +30,11 @@ public class ApiTestController {
public List<ProtocolDTO> getProtocols(@PathVariable String organizationId) {
return apiTestService.getProtocols(organizationId);
}
@GetMapping("/mock/{key}")
@Operation(summary = "获取mock数据")
public String mock(@PathVariable String key) {
return Mock.calculate(key).toString();
}
}

View File

@ -18,6 +18,7 @@ public class ApiTestControllerTests extends BaseTest {
private static final String BASE_PATH = "/api/test/";
protected static final String PROTOCOL_LIST = "protocol/{0}";
protected static final String MOCK = "mock/{0}";
@Override
protected String getBasePath() {
@ -29,4 +30,10 @@ public class ApiTestControllerTests extends BaseTest {
// @@请求成功
this.requestGetWithOk(PROTOCOL_LIST, this.DEFAULT_ORGANIZATION_ID).andReturn();
}
@Test
public void getMock() throws Exception {
// @@请求成功
this.requestGetWithOk(MOCK, "@integer").andReturn();
}
}

View File

@ -27,7 +27,7 @@
<dom4j.version>2.1.4</dom4j.version>
<guava.version>32.0.1-jre</guava.version>
<pagehelper.version>6.0.0</pagehelper.version>
<metersphere-jmeter-functions.version>1.5</metersphere-jmeter-functions.version>
<metersphere-jmeter-functions.version>3.0</metersphere-jmeter-functions.version>
<quartz-starter.version>1.0.7</quartz-starter.version>
<redisson-starter.version>3.23.5</redisson-starter.version>
<guice.version>5.1.0</guice.version>