diff --git a/test-test/src/main/java/com/test/test/controller/TestCaseController.java b/test-test/src/main/java/com/test/test/controller/TestCaseController.java index 0f3f7fb..d388eb8 100644 --- a/test-test/src/main/java/com/test/test/controller/TestCaseController.java +++ b/test-test/src/main/java/com/test/test/controller/TestCaseController.java @@ -6,6 +6,7 @@ import com.test.common.core.domain.AjaxResult; import com.test.common.core.page.TableDataInfo; import com.test.common.enums.BusinessType; import com.test.common.utils.DateUtils; +import com.test.common.utils.uuid.IdUtils; import com.test.test.domain.TestCase; import com.test.test.domain.qo.IDQO; import com.test.test.domain.qo.TestCaseListQO; @@ -82,16 +83,29 @@ public class TestCaseController extends BaseController { } /** - * 执行用例 + * 异步执行用例 */ @Log(title = "用例", businessType = BusinessType.OTHER) @PostMapping("/run") public AjaxResult run(@RequestBody IDQO qo) { log.info("执行用例 id:{}, jmeterHomePath:{}", qo.getId(), jmeterHomePath); + String caseSid = IdUtils.simpleUUID(); // 异步执行任务 CompletableFuture.runAsync(() -> { - testCaseService.executeTestCaseById(qo.getId(), jmeterHomePath); + testCaseService.executeTestCaseById(qo.getId(), jmeterHomePath, caseSid); }); return toAjax(true); } + + /** + * 同步执行用例 + */ + @Log(title = "用例", businessType = BusinessType.OTHER) + @PostMapping("/runSync") + public AjaxResult runSync(@RequestBody IDQO qo) { + log.info("同步执行用例 id:{}, jmeterHomePath:{}", qo.getId(), jmeterHomePath); + String caseSid = IdUtils.simpleUUID(); + testCaseService.executeTestCaseById(qo.getId(), jmeterHomePath, caseSid); + return AjaxResult.success("执行成功", caseSid); + } } diff --git a/test-test/src/main/java/com/test/test/service/ITestCaseService.java b/test-test/src/main/java/com/test/test/service/ITestCaseService.java index ef2a598..aa6ba98 100644 --- a/test-test/src/main/java/com/test/test/service/ITestCaseService.java +++ b/test-test/src/main/java/com/test/test/service/ITestCaseService.java @@ -66,7 +66,8 @@ public interface ITestCaseService * * @param id 用例主键id * @param jmeterHomePath jmeter安装路径 + * @param caseSid 用例执行uuid * @return 是否成功 */ - public String executeTestCaseById(Long id, String jmeterHomePath); + public String executeTestCaseById(Long id, String jmeterHomePath, String caseSid); } diff --git a/test-test/src/main/java/com/test/test/service/impl/TaskManagerService.java b/test-test/src/main/java/com/test/test/service/impl/TaskManagerService.java index 391df43..781c2ba 100644 --- a/test-test/src/main/java/com/test/test/service/impl/TaskManagerService.java +++ b/test-test/src/main/java/com/test/test/service/impl/TaskManagerService.java @@ -1,6 +1,7 @@ package com.test.test.service.impl; import com.test.common.utils.DateUtils; +import com.test.common.utils.uuid.IdUtils; import com.test.test.domain.TestTask; import com.test.test.domain.TestTaskCase; import com.test.test.domain.TestTaskResult; @@ -139,11 +140,12 @@ public class TaskManagerService { try { // 测试用例执行逻辑 log.info("Executing test case {} for task {}", testCaseId, taskId); - String result = testCaseService.executeTestCaseById(testCaseId, jmeterHomePath); + String caseSid = IdUtils.simpleUUID(); + String result = testCaseService.executeTestCaseById(testCaseId, jmeterHomePath, caseSid); if (result==null && retry == 0) { if (retryCount != null && retryCount > 0) { for (int i = 0; i < retryCount; i++) { - result = testCaseService.executeTestCaseById(testCaseId, jmeterHomePath); + result = testCaseService.executeTestCaseById(testCaseId, jmeterHomePath, caseSid); if (result!=null) { break; } diff --git a/test-test/src/main/java/com/test/test/service/impl/TestCaseServiceImpl.java b/test-test/src/main/java/com/test/test/service/impl/TestCaseServiceImpl.java index 4740ace..90247ee 100644 --- a/test-test/src/main/java/com/test/test/service/impl/TestCaseServiceImpl.java +++ b/test-test/src/main/java/com/test/test/service/impl/TestCaseServiceImpl.java @@ -9,7 +9,6 @@ import com.test.common.utils.JMeterUtil; import com.test.common.utils.MySQLExecutor; import com.test.common.utils.StringUtils; import com.test.common.utils.sql.TinyIntTypeAdapter; -import com.test.common.utils.uuid.IdUtils; import com.test.test.domain.*; import com.test.test.domain.qo.*; import com.test.test.mapper.TestCaseLogMapper; @@ -132,10 +131,11 @@ public class TestCaseServiceImpl implements ITestCaseService * * @param id 用例主键id * @param jmeterHomePath jmeter安装路径 + * @param caseSid 用例执行uuid * @return 是否成功 */ @Override - public String executeTestCaseById(Long id, String jmeterHomePath) { + public String executeTestCaseById(Long id, String jmeterHomePath, String caseSid) { TestCase testCase = this.selectTestCaseById(id); if (testCase == null || "2".equals(testCase.getDelFlag())) { log.error("用例计划已被删除,不能执行!"); @@ -145,9 +145,8 @@ public class TestCaseServiceImpl implements ITestCaseService testCase.setContextResultMap(contextResultMap); TestCaseLog testCaseLog = new TestCaseLog(); testCaseLog.setCaseId(id); - testCaseLog.setCreateTime(DateUtils.getNowDate()); + testCaseLog.setOperTime(DateUtils.getNowDate()); testCaseLog.setOperType("执行"); - String caseSid = IdUtils.simpleUUID(); testCaseLog.setCaseSid(caseSid); testCase.setCaseSid(caseSid); List testCaseStepList = testCaseStepService.selectTestCaseStepListByCaseId(id); @@ -632,6 +631,12 @@ public class TestCaseServiceImpl implements ITestCaseService } else { ruleResult.setResult("未通过"); } + } else if ("不等于".equals(fn)) { + if (!target.equals(value)) { + ruleResult.setResult("通过"); + } else { + ruleResult.setResult("未通过"); + } } else { ruleResult.setResult("未通过"); } diff --git a/test-ui/src/api/test/case.js b/test-ui/src/api/test/case.js index 4a6ea63..dd6aefd 100644 --- a/test-ui/src/api/test/case.js +++ b/test-ui/src/api/test/case.js @@ -53,3 +53,13 @@ export function runCase(id) { data: {id} }) } + +// 同步执行用例 +export function runCaseSync(id) { + return request({ + url: '/test/case/runSync', + method: 'post', + data: {id}, + timeout: 60000 + }) +} diff --git a/test-ui/src/views/test/case/detail/page2.vue b/test-ui/src/views/test/case/detail/page2.vue index e794cb6..60a94d0 100644 --- a/test-ui/src/views/test/case/detail/page2.vue +++ b/test-ui/src/views/test/case/detail/page2.vue @@ -178,6 +178,32 @@ export default { let compareName = '${' + name + '}'; return this.extract_object.some(obj => obj.value === compareName); }, + handleTableEdit(e, flag, scope) { + if (flag === "assignment") { + if (e && this.form.assignment.length === scope.$index + 1) { + this.form.assignment.push({ + key: "", + value: "" + }) + } + } + if (flag === "assertion") { + if (e && this.form.assertion.length === scope.$index + 1) { + this.form.assertion.push({ + key: "", + value: "" + }) + } + } + }, + handleDelete(flag, scope) { + if (flag === "assignment") { + this.form.assignment.splice(scope.$index, 1) + } + if (flag === "assertion") { + this.form.assertion.splice(scope.$index, 1) + } + }, handleLogChange(val) { const selectedItem = this.form.testCaseResultList.find(item => item.title === val); if (selectedItem) { diff --git a/test-ui/src/views/test/case/index.vue b/test-ui/src/views/test/case/index.vue index 49795e8..723540d 100644 --- a/test-ui/src/views/test/case/index.vue +++ b/test-ui/src/views/test/case/index.vue @@ -33,7 +33,7 @@