用例步骤执行结果列表以及详情后端接口提交

This commit is contained in:
liangdaliang
2025-03-14 17:36:51 +08:00
parent 5c0b275eec
commit 2850a00f1d
9 changed files with 128 additions and 2 deletions

View File

@@ -0,0 +1,31 @@
package com.test.test.controller;
import com.test.common.core.controller.BaseController;
import com.test.common.core.domain.AjaxResult;
import com.test.test.domain.qo.IDQO;
import com.test.test.service.ITestCaseResultService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* 用例步骤执行报告Controller
*
* @author liangdl
* @date 2025-03-14
*/
@RestController
@RequestMapping("/test/testCaseStepResult")
public class TestCaseResultController extends BaseController
{
@Autowired
private ITestCaseResultService testCaseResultService;
/**
* 获取用例步骤执行报告详细信息
*/
@PostMapping(value = "/detail")
public AjaxResult getInfo(@RequestBody IDQO qo)
{
return success(testCaseResultService.selectTestCaseResultById(qo.getId()));
}
}

View File

@@ -79,4 +79,6 @@ public class TestCaseResult extends BaseEntity {
/** 执行结果 */
@Excel(name = "执行结果")
private String status;
private String title;
}

View File

@@ -137,4 +137,7 @@ public class TestCaseStep extends BaseEntity {
/** 循环或轮询的子步骤列表 */
private List<TestCaseStep> childrenList;
/** 执行结果历史列表 */
private List<TestCaseResult> testCaseResultList;
}

View File

@@ -28,6 +28,14 @@ public interface TestCaseResultMapper
*/
public List<TestCaseResult> selectTestCaseResultList(TestCaseResult testCaseResult);
/**
* 查询用例执行报告最小化列表
*
* @param testCaseResult 用例执行报告
* @return 用例执行报告集合
*/
public List<TestCaseResult> selectMinTestCaseResultList(TestCaseResult testCaseResult);
/**
* 新增用例执行报告
*

View File

@@ -28,6 +28,14 @@ public interface ITestCaseResultService
*/
public List<TestCaseResult> selectTestCaseResultList(TestCaseResult testCaseResult);
/**
* 查询用例执行报告最小化列表
*
* @param testCaseResult 用例执行报告
* @return 用例执行报告集合
*/
public List<TestCaseResult> selectMinTestCaseResultList(TestCaseResult testCaseResult);
/**
* 新增用例执行报告
*

View File

@@ -46,6 +46,18 @@ public class TestCaseResultServiceImpl implements ITestCaseResultService
return testCaseResultMapper.selectTestCaseResultList(testCaseResult);
}
/**
* 查询用例执行报告最小化列表
*
* @param testCaseResult 用例执行报告
* @return 用例执行报告
*/
@Override
public List<TestCaseResult> selectMinTestCaseResultList(TestCaseResult testCaseResult)
{
return testCaseResultMapper.selectMinTestCaseResultList(testCaseResult);
}
/**
* 新增用例执行报告
*

View File

@@ -3,14 +3,17 @@ package com.test.test.service.impl;
import com.test.common.core.domain.model.JmeterRequest;
import com.test.common.utils.DateUtils;
import com.test.common.utils.JMeterUtil;
import com.test.test.domain.TestCaseResult;
import com.test.test.domain.TestCaseStep;
import com.test.test.domain.qo.TestCaseStepAddQO;
import com.test.test.mapper.TestCaseStepMapper;
import com.test.test.service.ITestCaseResultService;
import com.test.test.service.ITestCaseStepService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.List;
import java.util.Map;
@@ -27,6 +30,9 @@ public class TestCaseStepServiceImpl implements ITestCaseStepService {
@Resource
private TestCaseStepMapper testCaseStepMapper;
@Resource
private ITestCaseResultService iTestCaseResultService;
/**
* 查询用例步骤
*
@@ -49,18 +55,57 @@ public class TestCaseStepServiceImpl implements ITestCaseStepService {
testCaseStep.setDelFlag("0");
List<TestCaseStep> caseStepParentList = testCaseStepMapper.selectTestCaseStepList(testCaseStep);
for (TestCaseStep testCaseStepParent : caseStepParentList) {
TestCaseResult testCaseResultQuery = new TestCaseResult();
testCaseResultQuery.setCaseId(testCaseStepParent.getCaseId());
testCaseResultQuery.setStepId(testCaseStepParent.getId());
List<TestCaseResult> testCaseResultList = iTestCaseResultService.selectMinTestCaseResultList(testCaseResultQuery);
if (!CollectionUtils.isEmpty(testCaseResultList)) {
int i = 1;
for (TestCaseResult testCaseResult : testCaseResultList) {
String dateStr = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, testCaseResult.getExecuteTime());
testCaseResult.setTitle("结果" + i + "" + dateStr + "),状态:" + testCaseResult.getStatus());
i ++;
}
}
testCaseStepParent.setTestCaseResultList(testCaseResultList);
if (testCaseStepParent.getType() > 2) {
// 加载子步骤
TestCaseStep testCaseStepChild = new TestCaseStep();
testCaseStepChild.setDelFlag("0");
testCaseStepChild.setParentId(testCaseStepParent.getId());
List<TestCaseStep> caseStepChildrenList = testCaseStepMapper.selectTestCaseStepList(testCaseStepChild);
testCaseStepParent.setChildrenList(caseStepChildrenList);
this.dealChildrenList(testCaseStepParent, caseStepChildrenList);
}
}
return caseStepParentList;
}
/**
* 处理子步骤节点结果记录
* @param testCaseStepParent
* @param caseStepChildrenList
*/
private void dealChildrenList(TestCaseStep testCaseStepParent, List<TestCaseStep> caseStepChildrenList) {
if (!CollectionUtils.isEmpty(caseStepChildrenList)) {
TestCaseResult testCaseResultQuery = new TestCaseResult();
for (TestCaseStep testCaseStepChild1 : caseStepChildrenList) {
testCaseResultQuery.setCaseId(testCaseStepChild1.getCaseId());
testCaseResultQuery.setStepId(testCaseStepChild1.getId());
List<TestCaseResult> testCaseResultList = iTestCaseResultService.selectMinTestCaseResultList(testCaseResultQuery);
if (!CollectionUtils.isEmpty(testCaseResultList)) {
int i = 1;
for (TestCaseResult testCaseResult : testCaseResultList) {
String dateStr = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, testCaseResult.getExecuteTime());
testCaseResult.setTitle("结果" + i + "" + dateStr + "),状态:" + testCaseResult.getStatus());
i ++;
}
}
testCaseStepChild1.setTestCaseResultList(testCaseResultList);
}
testCaseStepParent.setChildrenList(caseStepChildrenList);
}
}
/**
* 新增用例步骤
*

View File

@@ -26,6 +26,10 @@
select id, case_id, step_id, request_header, request_body, response_header, response_body, sql_result, polling_count, loop_count, assignment, assertion, use_time, execute_time, status from test_case_result
</sql>
<sql id="selectMinTestCaseResultVo">
select id, case_id, step_id, polling_count, loop_count, use_time, execute_time, status from test_case_result
</sql>
<select id="selectTestCaseResultList" parameterType="TestCaseResult" resultMap="TestCaseResultResult">
<include refid="selectTestCaseResultVo"/>
<where>
@@ -46,6 +50,18 @@
</where>
</select>
<select id="selectMinTestCaseResultList" parameterType="TestCaseResult" resultMap="TestCaseResultResult">
<include refid="selectMinTestCaseResultVo"/>
<where>
<if test="caseId != null "> and case_id = #{caseId}</if>
<if test="stepId != null "> and step_id = #{stepId}</if>
<if test="useTime != null "> and use_time = #{useTime}</if>
<if test="executeTime != null "> and execute_time = #{executeTime}</if>
<if test="status != null and status != ''"> and status = #{status}</if>
</where>
order by execute_time desc
</select>
<select id="selectTestCaseResultById" parameterType="Long" resultMap="TestCaseResultResult">
<include refid="selectTestCaseResultVo"/>
where id = #{id}

View File

@@ -5,7 +5,8 @@ export function listCaseStep(query) {
return request({
url: '/test/caseStep/list',
method: 'get',
params: query
params: query,
timeout: 10000
})
}