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 d388eb8..4e894e4 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 @@ -8,6 +8,7 @@ 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.TestPlanCase; import com.test.test.domain.qo.IDQO; import com.test.test.domain.qo.TestCaseListQO; import com.test.test.service.ITestCaseService; @@ -44,6 +45,16 @@ public class TestCaseController extends BaseController { return getDataTable(list); } + /** + * 查询测试计划可关联的用例列表 + */ + @GetMapping("/planRelateList") + public TableDataInfo planRelateList(TestCaseListQO qo) { + startPage(); + List list = testCaseService.selectValidTestPlanCaseList(qo); + return getDataTable(list); + } + /** * 获取用例详细信息 */ @@ -108,4 +119,18 @@ public class TestCaseController extends BaseController { testCaseService.executeTestCaseById(qo.getId(), jmeterHomePath, caseSid); return AjaxResult.success("执行成功", caseSid); } + + /** + * 异步执行测试计划用例 + */ + @Log(title = "用例", businessType = BusinessType.OTHER) + @PostMapping("/runTestPlanCase") + public AjaxResult runTestPlanCase(@RequestBody TestPlanCase testPlanCase) { + String caseSid = IdUtils.simpleUUID(); + // 异步执行任务 + CompletableFuture.runAsync(() -> { + testCaseService.executeTestCaseByPlanCase(testPlanCase, jmeterHomePath, caseSid); + }); + return toAjax(true); + } } diff --git a/test-test/src/main/java/com/test/test/controller/TestPlanCaseController.java b/test-test/src/main/java/com/test/test/controller/TestPlanCaseController.java new file mode 100644 index 0000000..636c68f --- /dev/null +++ b/test-test/src/main/java/com/test/test/controller/TestPlanCaseController.java @@ -0,0 +1,91 @@ +package com.test.test.controller; + +import com.test.common.annotation.Log; +import com.test.common.core.controller.BaseController; +import com.test.common.core.domain.AjaxResult; +import com.test.common.core.page.TableDataInfo; +import com.test.common.enums.BusinessType; +import com.test.test.domain.TestPlanCase; +import com.test.test.domain.qo.TestPlanCaseQO; +import com.test.test.service.ITestPlanCaseService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 测试计划用例关联Controller + * + * @author test + * @date 2025-04-25 + */ +@RestController +@RequestMapping("/test/planCase") +public class TestPlanCaseController extends BaseController +{ + @Autowired + private ITestPlanCaseService testPlanCaseService; + + /** + * 查询测试计划用例关联列表 + */ + @GetMapping("/list") + public TableDataInfo list(TestPlanCase testPlanCase) + { + startPage(); + List list = testPlanCaseService.selectTestPlanCaseList(testPlanCase); + return getDataTable(list); + } + + /** + * 导出测试计划用例关联列表 + */ +// @Log(title = "测试计划用例关联", businessType = BusinessType.EXPORT) +// @PostMapping("/export") +// public void export(HttpServletResponse response, TestPlanCase testPlanCase) +// { +// List list = testPlanCaseService.selectTestPlanCaseList(testPlanCase); +// ExcelUtil util = new ExcelUtil(TestPlanCase.class); +// util.exportExcel(response, list, "测试计划用例关联数据"); +// } + + /** + * 获取测试计划用例关联详细信息 + */ +// @GetMapping(value = "/{id}") +// public AjaxResult getInfo(@PathVariable("id") Long id) +// { +// return success(testPlanCaseService.selectTestPlanCaseById(id)); +// } + + /** + * 新增测试计划用例关联 + */ + @Log(title = "测试计划用例关联", businessType = BusinessType.INSERT) + @PostMapping(value = "/saveRelate") + public AjaxResult saveRelate(@RequestBody TestPlanCaseQO qo) + { + testPlanCaseService.saveRelate(qo); + return success(qo); + } + + /** + * 修改测试计划用例关联 + */ +// @Log(title = "测试计划用例关联", businessType = BusinessType.UPDATE) +// @PutMapping +// public AjaxResult edit(@RequestBody TestPlanCase testPlanCase) +// { +// return toAjax(testPlanCaseService.updateTestPlanCase(testPlanCase)); +// } + + /** + * 删除测试计划用例关联 + */ + @Log(title = "测试计划用例关联", businessType = BusinessType.DELETE) + @PostMapping("/delRelate/{ids}") + public AjaxResult remove(@PathVariable("ids") Long[] ids) + { + return toAjax(testPlanCaseService.deleteTestPlanCaseByIds(ids)); + } +} diff --git a/test-test/src/main/java/com/test/test/domain/TestPlanCase.java b/test-test/src/main/java/com/test/test/domain/TestPlanCase.java new file mode 100644 index 0000000..95e6e78 --- /dev/null +++ b/test-test/src/main/java/com/test/test/domain/TestPlanCase.java @@ -0,0 +1,61 @@ +package com.test.test.domain; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.test.common.annotation.Excel; +import com.test.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 测试计划用例关联对象 test_plan_case + * + * @author test + * @date 2025-04-25 + */ +@EqualsAndHashCode(callSuper = true) +@Data +public class TestPlanCase extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键 */ + private Long id; + + /** 测试计划主键ID */ + @Excel(name = "测试计划主键ID") + private Long planId; + + /** 用例主键ID */ + @Excel(name = "用例主键ID") + private Long caseId; + + /** 测试用例类型(0,冒烟测试,1,功能测试,2,回归测试,3,准生产测试,4,生产验证) */ + @Excel(name = "测试用例类型(0,冒烟测试,1,功能测试,2,回归测试,3,准生产测试,4,生产验证)") + private Integer type; + + /** 未执行、成功或失败 */ + @Excel(name = "未执行、成功或失败") + private String executeResult; + + /** 执行时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "执行时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date executeTime; + + /** 执行人 */ + @Excel(name = "执行人") + private String executeBy; + + /** 版本 */ + @Excel(name = "版本") + private String version; + + /** 0,正常,1,删除 */ + private String delFlag; + + /** 未执行、成功或失败 */ + @Excel(name = "用例名称") + private String caseName; +} diff --git a/test-test/src/main/java/com/test/test/domain/qo/TestCaseListQO.java b/test-test/src/main/java/com/test/test/domain/qo/TestCaseListQO.java index 56ed405..056603c 100644 --- a/test-test/src/main/java/com/test/test/domain/qo/TestCaseListQO.java +++ b/test-test/src/main/java/com/test/test/domain/qo/TestCaseListQO.java @@ -3,8 +3,18 @@ package com.test.test.domain.qo; import jakarta.validation.constraints.NotNull; import lombok.Data; +import java.io.Serializable; + @Data -public class TestCaseListQO { +public class TestCaseListQO implements Serializable { + + private static final long serialVersionUID = 4636502018355979101L; @NotNull(message = "父节点id不能为空") private Long groupId; + /** 测试计划主键ID */ + private Long planId; + /** + * 测试用例类型(0,冒烟测试,1,功能测试,2,回归测试,3,准生产测试,4,生产验证) + */ + private Integer type; } diff --git a/test-test/src/main/java/com/test/test/domain/qo/TestPlanCaseQO.java b/test-test/src/main/java/com/test/test/domain/qo/TestPlanCaseQO.java new file mode 100644 index 0000000..c9604d1 --- /dev/null +++ b/test-test/src/main/java/com/test/test/domain/qo/TestPlanCaseQO.java @@ -0,0 +1,20 @@ +package com.test.test.domain.qo; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @author liangdaliang + * @Description:测试计划关联用例 + * @date 2025-04-27 13:16 + */ +@Data +public class TestPlanCaseQO implements Serializable { + + private static final long serialVersionUID = 4636202018365979101L; + private Long planId; + private Integer type; + private List testCaseIdList; +} diff --git a/test-test/src/main/java/com/test/test/mapper/TestCaseMapper.java b/test-test/src/main/java/com/test/test/mapper/TestCaseMapper.java index ddf6d6f..345abe6 100644 --- a/test-test/src/main/java/com/test/test/mapper/TestCaseMapper.java +++ b/test-test/src/main/java/com/test/test/mapper/TestCaseMapper.java @@ -20,6 +20,11 @@ public interface TestCaseMapper */ List selectTestCaseList(TestCaseListQO qo); + /** + * 查询测试计划可关联的用例列表 + */ + List selectValidTestPlanCaseList(TestCaseListQO qo); + /** * 查询用例列表 */ diff --git a/test-test/src/main/java/com/test/test/mapper/TestPlanCaseMapper.java b/test-test/src/main/java/com/test/test/mapper/TestPlanCaseMapper.java new file mode 100644 index 0000000..80780aa --- /dev/null +++ b/test-test/src/main/java/com/test/test/mapper/TestPlanCaseMapper.java @@ -0,0 +1,62 @@ +package com.test.test.mapper; + +import com.test.test.domain.TestPlanCase; + +import java.util.List; + +/** + * 测试计划用例关联Mapper接口 + * + * @author test + * @date 2025-04-25 + */ +public interface TestPlanCaseMapper +{ + /** + * 查询测试计划用例关联 + * + * @param id 测试计划用例关联主键 + * @return 测试计划用例关联 + */ + public TestPlanCase selectTestPlanCaseById(Long id); + + /** + * 查询测试计划用例关联列表 + * + * @param testPlanCase 测试计划用例关联 + * @return 测试计划用例关联集合 + */ + public List selectTestPlanCaseList(TestPlanCase testPlanCase); + + /** + * 新增测试计划用例关联 + * + * @param testPlanCase 测试计划用例关联 + * @return 结果 + */ + public int insertTestPlanCase(TestPlanCase testPlanCase); + + /** + * 修改测试计划用例关联 + * + * @param testPlanCase 测试计划用例关联 + * @return 结果 + */ + public int updateTestPlanCase(TestPlanCase testPlanCase); + + /** + * 删除测试计划用例关联 + * + * @param id 测试计划用例关联主键 + * @return 结果 + */ + public int deleteTestPlanCaseById(Long id); + + /** + * 批量删除测试计划用例关联 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteTestPlanCaseByIds(Long[] ids); +} 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 b698465..5d1b194 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 @@ -1,6 +1,7 @@ package com.test.test.service; import com.test.test.domain.TestCase; +import com.test.test.domain.TestPlanCase; import com.test.test.domain.qo.TestCaseListQO; import java.util.List; @@ -29,6 +30,13 @@ public interface ITestCaseService */ public List selectTestCaseList(TestCaseListQO qo); + /** + * 查询测试计划可关联的用例列表 + * @param qo 用例 + * @return 用例集合 + */ + public List selectValidTestPlanCaseList(TestCaseListQO qo); + /** * 查询用例列表 * @param testCase @@ -77,4 +85,14 @@ public interface ITestCaseService * @return 是否成功 */ public String executeTestCaseById(Long id, String jmeterHomePath, String caseSid); + + /** + * 执行测试计划关联的用例 + * + * @param testPlanCase 测试计划关联用例查询条件 + * @param jmeterHomePath jmeter安装路径 + * @param caseSid 用例执行uuid + * @return 是否成功 + */ + public void executeTestCaseByPlanCase(TestPlanCase testPlanCase, String jmeterHomePath, String caseSid); } diff --git a/test-test/src/main/java/com/test/test/service/ITestPlanCaseService.java b/test-test/src/main/java/com/test/test/service/ITestPlanCaseService.java new file mode 100644 index 0000000..17618d9 --- /dev/null +++ b/test-test/src/main/java/com/test/test/service/ITestPlanCaseService.java @@ -0,0 +1,71 @@ +package com.test.test.service; + +import com.test.test.domain.TestPlanCase; +import com.test.test.domain.qo.TestPlanCaseQO; + +import java.util.List; + +/** + * 测试计划用例关联Service接口 + * + * @author test + * @date 2025-04-25 + */ +public interface ITestPlanCaseService +{ + /** + * 查询测试计划用例关联 + * + * @param id 测试计划用例关联主键 + * @return 测试计划用例关联 + */ + public TestPlanCase selectTestPlanCaseById(Long id); + + /** + * 查询测试计划用例关联列表 + * + * @param testPlanCase 测试计划用例关联 + * @return 测试计划用例关联集合 + */ + public List selectTestPlanCaseList(TestPlanCase testPlanCase); + + /** + * 保存测试计划用例关联列表 + * + * @param testPlanCaseQO 测试计划用例关联 + * @return + */ + public void saveRelate(TestPlanCaseQO testPlanCaseQO); + + /** + * 新增测试计划用例关联 + * + * @param testPlanCase 测试计划用例关联 + * @return 结果 + */ + public int insertTestPlanCase(TestPlanCase testPlanCase); + + /** + * 修改测试计划用例关联 + * + * @param testPlanCase 测试计划用例关联 + * @return 结果 + */ + public int updateTestPlanCase(TestPlanCase testPlanCase); + + /** + * 批量删除测试计划用例关联 + * + * @param ids 需要删除的测试计划用例关联主键集合 + * @return 结果 + */ + public int deleteTestPlanCaseByIds(Long[] ids); + + /** + * 删除测试计划用例关联信息 + * + * @param id 测试计划用例关联主键 + * @return 结果 + */ + public int deleteTestPlanCaseById(Long id); +} 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 9ea3aca..6546220 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 @@ -4,17 +4,11 @@ import com.fatboyindustrial.gsonjavatime.LocalDateTimeConverter; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.reflect.TypeToken; -import com.test.common.utils.DateUtils; -import com.test.common.utils.JMeterUtil; -import com.test.common.utils.MySQLExecutor; -import com.test.common.utils.StringUtils; +import com.test.common.utils.*; import com.test.common.utils.sql.TinyIntTypeAdapter; import com.test.test.domain.*; import com.test.test.domain.qo.*; -import com.test.test.mapper.TestCaseLogMapper; -import com.test.test.mapper.TestCaseMapper; -import com.test.test.mapper.TestCaseResultMapper; -import com.test.test.mapper.TestDatasourceMapper; +import com.test.test.mapper.*; import com.test.test.service.ITestCaseService; import com.test.test.service.ITestCaseStepService; import jakarta.annotation.Resource; @@ -49,6 +43,10 @@ public class TestCaseServiceImpl implements ITestCaseService private TestDatasourceMapper testDatasourceMapper; @Resource private TestCaseLogMapper testCaseLogMapper; + @Resource + private TestPlanMapper testPlanMapper; + @Resource + private TestPlanCaseMapper testPlanCaseMapper; @Autowired private ITestCaseStepService testCaseStepService; @@ -76,6 +74,14 @@ public class TestCaseServiceImpl implements ITestCaseService return testCaseMapper.selectTestCaseList(qo); } + /** + * 查询测试计划可关联的用例列表 + */ + @Override + public List selectValidTestPlanCaseList(TestCaseListQO qo) { + return testCaseMapper.selectValidTestPlanCaseList(qo); + } + @Override public List selectTestCaseList(TestCase testCase) { return testCaseMapper.selectTestCaseListNoGroupId(testCase); @@ -201,6 +207,102 @@ public class TestCaseServiceImpl implements ITestCaseService return caseSid; } + /** + * 执行测试计划关联的用例 + * + * @param testPlanCase 测试计划关联用例查询条件 + * @param jmeterHomePath jmeter安装路径 + * @param caseSid 用例执行uuid + * @return 是否成功 + */ + @Override + public void executeTestCaseByPlanCase(TestPlanCase testPlanCase, String jmeterHomePath, String caseSid) { + List testPlanCaseList = testPlanCaseMapper.selectTestPlanCaseList(testPlanCase); + if (CollectionUtils.isEmpty(testPlanCaseList)) { + log.error("计划关联测试用例为空,不能执行!"); + return ; + } + TestPlan testPlan = testPlanMapper.selectTestPlanById(testPlanCase.getPlanId()); + testPlan.setStatus("1"); + testPlan.setUpdateTime(DateUtils.getNowDate()); + testPlanMapper.updateTestPlan(testPlan); + for (TestPlanCase input : testPlanCaseList) { + boolean isSuccess = true; + input.setExecuteTime(DateUtils.getNowDate()); + input.setExecuteBy(SecurityUtils.getUsername()); + TestCase testCase = this.selectTestCaseById(input.getCaseId()); + Long id = input.getCaseId(); + Map contextResultMap = new HashMap<>(); + testCase.setContextResultMap(contextResultMap); + TestCaseLog testCaseLog = new TestCaseLog(); + testCaseLog.setCaseId(id); + testCaseLog.setOperTime(DateUtils.getNowDate()); + testCaseLog.setOperType("执行"); + testCaseLog.setCaseSid(caseSid); + testCase.setCaseSid(caseSid); + List testCaseStepList = testCaseStepService.selectTestCaseStepListByCaseId(id); + for (TestCaseStep testCaseStep : testCaseStepList) { + if (testCaseStep.getType() == 1L) { + // http接口处理 + boolean httpTestResult = doHttpRequestTest(testCase, testCaseStep, jmeterHomePath); + if (!httpTestResult) { + testCaseLog.setOperDetail("失败"); + testCaseLogMapper.insertTestCaseLog(testCaseLog); + log.error("用例步骤:{}执行失败!", testCaseStep.getName()); + isSuccess = false; + break; + } + } else if (testCaseStep.getType() == 2L) { + // 数据库接口处理 + boolean dateSourceTestResult = doDateSourceRequestTest(testCase, testCaseStep); + if (!dateSourceTestResult) { + testCaseLog.setOperDetail("失败"); + testCaseLogMapper.insertTestCaseLog(testCaseLog); + log.error("数据源用例步骤:{}执行失败!", testCaseStep.getName()); + isSuccess = false; + break; + } + } else if (testCaseStep.getType() == 3L) { + // 循环节点处理 + boolean pollTestResult = doPollRequestTest(testCase, testCaseStep, jmeterHomePath); + if (!pollTestResult) { + testCaseLog.setOperDetail("失败"); + testCaseLogMapper.insertTestCaseLog(testCaseLog); + log.error("循环用例步骤:{}执行失败!", testCaseStep.getName()); + isSuccess = false; + break; + } + } else if (testCaseStep.getType() == 4L) { + // 轮询节点处理 + boolean loopTestResult = doLoopRequestTest(testCase, testCaseStep, jmeterHomePath); + if (!loopTestResult) { + testCaseLog.setOperDetail("失败"); + testCaseLogMapper.insertTestCaseLog(testCaseLog); + log.error("轮询用例步骤:{}执行失败!", testCaseStep.getName()); + isSuccess = false; + break; + } + } else { + log.error("错误的用例步骤类型!"); + isSuccess = false; + break; + } + } + if (isSuccess) { + testCaseLog.setOperDetail("成功"); + input.setExecuteResult("成功"); + } else { + testCaseLog.setOperDetail("失败"); + input.setExecuteResult("失败"); + } + testCaseLogMapper.insertTestCaseLog(testCaseLog); + testPlanCaseMapper.updateTestPlanCase(input); + } + testPlan.setUpdateTime(DateUtils.getNowDate()); + testPlan.setStatus("2"); + testPlanMapper.updateTestPlan(testPlan); + } + /** * 处理http接口测试 * @param testCase diff --git a/test-test/src/main/java/com/test/test/service/impl/TestPlanCaseServiceImpl.java b/test-test/src/main/java/com/test/test/service/impl/TestPlanCaseServiceImpl.java new file mode 100644 index 0000000..396941b --- /dev/null +++ b/test-test/src/main/java/com/test/test/service/impl/TestPlanCaseServiceImpl.java @@ -0,0 +1,126 @@ +package com.test.test.service.impl; + +import com.test.common.utils.DateUtils; +import com.test.common.utils.SecurityUtils; +import com.test.test.domain.TestPlanCase; +import com.test.test.domain.qo.TestPlanCaseQO; +import com.test.test.mapper.TestPlanCaseMapper; +import com.test.test.service.ITestPlanCaseService; +import jakarta.annotation.Resource; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import java.util.List; + +/** + * 测试计划用例关联Service业务层处理 + * + * @author test + * @date 2025-04-25 + */ +@Service +public class TestPlanCaseServiceImpl implements ITestPlanCaseService +{ + @Resource + private TestPlanCaseMapper testPlanCaseMapper; + + /** + * 查询测试计划用例关联 + * + * @param id 测试计划用例关联主键 + * @return 测试计划用例关联 + */ + @Override + public TestPlanCase selectTestPlanCaseById(Long id) + { + return testPlanCaseMapper.selectTestPlanCaseById(id); + } + + /** + * 查询测试计划用例关联列表 + * + * @param testPlanCase 测试计划用例关联 + * @return 测试计划用例关联 + */ + @Override + public List selectTestPlanCaseList(TestPlanCase testPlanCase) + { + return testPlanCaseMapper.selectTestPlanCaseList(testPlanCase); + } + + /** + * 保存测试计划用例关联列表 + * + * @param testPlanCaseQO 测试计划用例关联 + * @return + */ + @Override + public void saveRelate(TestPlanCaseQO testPlanCaseQO) + { + List testCaseIdList = testPlanCaseQO.getTestCaseIdList(); + for (Long testCaseId : testCaseIdList) { + TestPlanCase testPlanCase = new TestPlanCase(); + testPlanCase.setPlanId(testPlanCaseQO.getPlanId()); + testPlanCase.setCaseId(testCaseId); + testPlanCase.setType(testPlanCaseQO.getType()); + List testPlanCaseList = selectTestPlanCaseList(testPlanCase); + if (!CollectionUtils.isEmpty(testPlanCaseList)) { + // 防止重复 + continue; + } + testPlanCase.setCreateBy(SecurityUtils.getUsername()); + testPlanCase.setCreateTime(DateUtils.getNowDate()); + testPlanCaseMapper.insertTestPlanCase(testPlanCase); + } + } + + /** + * 新增测试计划用例关联 + * + * @param testPlanCase 测试计划用例关联 + * @return 结果 + */ + @Override + public int insertTestPlanCase(TestPlanCase testPlanCase) + { + testPlanCase.setCreateTime(DateUtils.getNowDate()); + return testPlanCaseMapper.insertTestPlanCase(testPlanCase); + } + + /** + * 修改测试计划用例关联 + * + * @param testPlanCase 测试计划用例关联 + * @return 结果 + */ + @Override + public int updateTestPlanCase(TestPlanCase testPlanCase) + { + testPlanCase.setUpdateTime(DateUtils.getNowDate()); + return testPlanCaseMapper.updateTestPlanCase(testPlanCase); + } + + /** + * 批量删除测试计划用例关联 + * + * @param ids 需要删除的测试计划用例关联主键 + * @return 结果 + */ + @Override + public int deleteTestPlanCaseByIds(Long[] ids) + { + return testPlanCaseMapper.deleteTestPlanCaseByIds(ids); + } + + /** + * 删除测试计划用例关联信息 + * + * @param id 测试计划用例关联主键 + * @return 结果 + */ + @Override + public int deleteTestPlanCaseById(Long id) + { + return testPlanCaseMapper.deleteTestPlanCaseById(id); + } +} diff --git a/test-test/src/main/resources/mapper/test/TestCaseMapper.xml b/test-test/src/main/resources/mapper/test/TestCaseMapper.xml index c3ea6e7..6132466 100644 --- a/test-test/src/main/resources/mapper/test/TestCaseMapper.xml +++ b/test-test/src/main/resources/mapper/test/TestCaseMapper.xml @@ -41,6 +41,30 @@ order by create_time desc + + + SELECT + tp.id, + tp.case_id, + tc.name , + tp.execute_result, + tp.create_by, + tp.execute_by, + tp.execute_time, + tp.create_time + FROM test_plan_case tp + LEFT JOIN test_case tc ON tc.id = tp.case_id + where tp.del_flag = '0' + AND tc.name LIKE concat('%', #{caseName}, '%') + and case_id = #{caseId} + and type = #{type} + and plan_id = #{planId} + + + + + + insert into test_plan_case + + id, + plan_id, + case_id, + type, + execute_result, + create_time, + create_by, + update_time, + execute_time, + execute_by, + version, + del_flag, + + + #{id}, + #{planId}, + #{caseId}, + #{type}, + #{executeResult}, + #{createTime}, + #{createBy}, + #{updateTime}, + #{executeTime}, + #{executeBy}, + #{version}, + #{delFlag}, + + + + + update test_plan_case + + plan_id = #{planId}, + case_id = #{caseId}, + type = #{type}, + execute_result = #{executeResult}, + create_time = #{createTime}, + create_by = #{createBy}, + update_time = #{updateTime}, + execute_time = #{executeTime}, + execute_by = #{executeBy}, + version = #{version}, + del_flag = #{delFlag}, + + where id = #{id} + + + + delete from test_plan_case where id = #{id} + + + + delete from test_plan_case where id in + + #{id} + + + diff --git a/test-ui/src/api/test/planCase.js b/test-ui/src/api/test/planCase.js new file mode 100644 index 0000000..ac8c80e --- /dev/null +++ b/test-ui/src/api/test/planCase.js @@ -0,0 +1,51 @@ +import request from '@/utils/request' + +const api = { + planCaseList: 'test/planCase/list', + relateCaseList: '/test/case/planRelateList', + saveRelate: 'test/planCase/saveRelate', + delRelate: 'test/planCase/delRelate/', +} + +export function getPlanCaseList(data) { + return request({ + url: api.planCaseList, + method: 'get', + params: data + }) +} + +// 查询可关联的用例列表 +export function getRelateCaseList(data) { + return request({ + url: api.relateCaseList, + method: 'get', + params: data + }) +} + +export function saveRelate(data) { + return request({ + url: api.saveRelate, + method: 'post', + data + }) +} + +export function delRelate(id) { + return request({ + url: api.delRelate + id, + method: 'post', + data: {id} + }) +} + +// 执行用例 +export function runTestPlanCase(data) { + return request({ + url: '/test/case/runTestPlanCase', + method: 'post', + data + }) +} + diff --git a/test-ui/src/router/index.js b/test-ui/src/router/index.js index 2fd72ea..91bafd6 100644 --- a/test-ui/src/router/index.js +++ b/test-ui/src/router/index.js @@ -130,6 +130,20 @@ export const constantRoutes = [ } ] }, + { + path: '/testplan/execute', + component: Layout, + hidden: true, + children: [ + { + path: '', + component: () => import('@/views/test/testplan/execute/index'), + name: 'PlanExecute', + noCache: true, + meta: { title: '计划执行', activeMenu: '/testplan' } + } + ] + }, { path: '/task/detail', component: Layout, diff --git a/test-ui/src/views/test/case/index.vue b/test-ui/src/views/test/case/index.vue index 723540d..3147b6d 100644 --- a/test-ui/src/views/test/case/index.vue +++ b/test-ui/src/views/test/case/index.vue @@ -14,7 +14,7 @@ diff --git a/test-ui/src/views/test/testplan/execute/index.vue b/test-ui/src/views/test/testplan/execute/index.vue new file mode 100644 index 0000000..2970509 --- /dev/null +++ b/test-ui/src/views/test/testplan/execute/index.vue @@ -0,0 +1,267 @@ + + + + + diff --git a/test-ui/src/views/test/testplan/execute/relateCase.vue b/test-ui/src/views/test/testplan/execute/relateCase.vue new file mode 100644 index 0000000..becdef3 --- /dev/null +++ b/test-ui/src/views/test/testplan/execute/relateCase.vue @@ -0,0 +1,80 @@ + + + + + + diff --git a/test-ui/src/views/test/testplan/index.vue b/test-ui/src/views/test/testplan/index.vue index affb466..9cc654f 100644 --- a/test-ui/src/views/test/testplan/index.vue +++ b/test-ui/src/views/test/testplan/index.vue @@ -255,6 +255,8 @@ @@ -478,6 +480,9 @@ export default { this.$modal.msgSuccess("删除成功"); }); }, + handlePlanRun(row) { + this.$tab.openPage(`计划执行[${row.name}]`, "/testplan/execute", {id: row.id, name: row.name}); + }, editSubmitForm() { const form = { ...this.editForm,