测试用例执行相关优化
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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<TestCaseStep> 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("未通过");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user