新增执行用例前端及控制层逻辑
This commit is contained in:
@@ -10,6 +10,8 @@ test:
|
|||||||
profile: D:/test/uploadPath
|
profile: D:/test/uploadPath
|
||||||
# 获取ip地址开关
|
# 获取ip地址开关
|
||||||
addressEnabled: true
|
addressEnabled: true
|
||||||
|
# Jmeter主目录路径
|
||||||
|
jmeterHomePath: /opt/apache-jmeter
|
||||||
|
|
||||||
# 开发环境配置
|
# 开发环境配置
|
||||||
server:
|
server:
|
||||||
|
|||||||
@@ -1,31 +1,34 @@
|
|||||||
package com.test.test.controller;
|
package com.test.test.controller;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.test.common.utils.DateUtils;
|
|
||||||
import com.test.test.domain.qo.IDQO;
|
|
||||||
import com.test.test.domain.qo.TestCaseListQO;
|
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import com.test.common.annotation.Log;
|
import com.test.common.annotation.Log;
|
||||||
import com.test.common.core.controller.BaseController;
|
import com.test.common.core.controller.BaseController;
|
||||||
import com.test.common.core.domain.AjaxResult;
|
import com.test.common.core.domain.AjaxResult;
|
||||||
import com.test.common.enums.BusinessType;
|
|
||||||
import com.test.test.domain.TestCase;
|
|
||||||
import com.test.test.service.ITestCaseService;
|
|
||||||
import com.test.common.core.page.TableDataInfo;
|
import com.test.common.core.page.TableDataInfo;
|
||||||
|
import com.test.common.enums.BusinessType;
|
||||||
|
import com.test.common.utils.DateUtils;
|
||||||
|
import com.test.test.domain.TestCase;
|
||||||
|
import com.test.test.domain.qo.IDQO;
|
||||||
|
import com.test.test.domain.qo.TestCaseListQO;
|
||||||
|
import com.test.test.service.ITestCaseService;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用例Controller
|
* 用例Controller
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/test/case")
|
@RequestMapping("/test/case")
|
||||||
public class TestCaseController extends BaseController {
|
public class TestCaseController extends BaseController {
|
||||||
|
|
||||||
|
@Value("${test.jmeterHomePath:/opt/apache-jmeter}")
|
||||||
|
private String jmeterHomePath;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ITestCaseService testCaseService;
|
private ITestCaseService testCaseService;
|
||||||
|
|
||||||
@@ -76,4 +79,14 @@ public class TestCaseController extends BaseController {
|
|||||||
public AjaxResult remove(@RequestBody IDQO qo) {
|
public AjaxResult remove(@RequestBody IDQO qo) {
|
||||||
return toAjax(testCaseService.deleteTestCaseById(qo.getId()));
|
return toAjax(testCaseService.deleteTestCaseById(qo.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行用例
|
||||||
|
*/
|
||||||
|
@Log(title = "用例", businessType = BusinessType.OTHER)
|
||||||
|
@PostMapping("/run")
|
||||||
|
public AjaxResult run(@RequestBody IDQO qo) {
|
||||||
|
log.info("执行用例 id:{}, jmeterHomePath:{}", qo.getId(), jmeterHomePath);
|
||||||
|
return toAjax(testCaseService.executeTestCaseById(qo.getId(), jmeterHomePath));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,3 +44,12 @@ export function delCase(id) {
|
|||||||
data: {id}
|
data: {id}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 执行用例
|
||||||
|
export function runCase(id) {
|
||||||
|
return request({
|
||||||
|
url: '/test/case/run',
|
||||||
|
method: 'post',
|
||||||
|
data: {id}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import FolderPage from "@/components/FolderPage/index.vue";
|
import FolderPage from "@/components/FolderPage/index.vue";
|
||||||
import {addCase, delCase, listCase} from "@/api/test/case";
|
import {addCase, delCase, listCase, runCase} from "@/api/test/case";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Case",
|
name: "Case",
|
||||||
@@ -81,7 +81,11 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
handleRun(id) {
|
handleRun(id) {
|
||||||
console.log(id)
|
this.$modal.confirm('是否确认执行用例?').then(function () {
|
||||||
|
return runCase(id);
|
||||||
|
}).then(() => {
|
||||||
|
this.$modal.msgSuccess("执行成功");
|
||||||
|
});
|
||||||
},
|
},
|
||||||
handleRowClick(row) {
|
handleRowClick(row) {
|
||||||
this.$tab.openPage(`用例[${row.name}]`, "/case/detail", {id: row.id});
|
this.$tab.openPage(`用例[${row.name}]`, "/case/detail", {id: row.id});
|
||||||
|
|||||||
Reference in New Issue
Block a user