feat(测试计划): 报告功能用例查看执行结果

--story=1015333 --user=宋昌昌 【测试计划】完成剩余功能 https://www.tapd.cn/55049933/s/1543354
This commit is contained in:
song-cc-rock 2024-07-03 16:05:02 +08:00 committed by Craftsman
parent 307be50c14
commit d37fe74580
7 changed files with 78 additions and 1 deletions

View File

@ -8,6 +8,7 @@ import io.metersphere.plan.constants.AssociateCaseType;
import io.metersphere.plan.constants.TestPlanResourceConfig;
import io.metersphere.plan.dto.ReportDetailCasePageDTO;
import io.metersphere.plan.dto.request.*;
import io.metersphere.plan.dto.response.TestPlanCaseExecHistoryResponse;
import io.metersphere.plan.dto.response.TestPlanReportDetailResponse;
import io.metersphere.plan.dto.response.TestPlanReportPageResponse;
import io.metersphere.plan.service.*;
@ -141,6 +142,14 @@ public class TestPlanReportController {
return PageUtils.setPageInfo(page, testPlanReportService.listReportDetailCases(request, AssociateCaseType.FUNCTIONAL));
}
@GetMapping("/detail/functional/case/step/{reportId}")
@Operation(summary = "测试计划-报告-详情-功能用例-执行步骤结果")
@RequiresPermissions(value = {PermissionConstants.TEST_PLAN_REPORT_READ, PermissionConstants.TEST_PLAN_READ_EXECUTE}, logical = Logical.OR)
@CheckOwner(resourceId = "#reportId", resourceType = "test_plan_case_execute_history")
public TestPlanCaseExecHistoryResponse getFunctionalExecuteResult(@PathVariable String reportId) {
return testPlanReportService.getFunctionalExecuteResult(reportId);
}
@PostMapping("/detail/api/case/page")
@Operation(summary = "测试计划-报告-详情-接口用例分页查询")
@RequiresPermissions(value = {PermissionConstants.TEST_PLAN_REPORT_READ, PermissionConstants.TEST_PLAN_READ_EXECUTE}, logical = Logical.OR)

View File

@ -14,6 +14,7 @@ import io.metersphere.plan.dto.ReportDetailCasePageDTO;
import io.metersphere.plan.dto.TestPlanShareInfo;
import io.metersphere.plan.dto.request.TestPlanReportShareRequest;
import io.metersphere.plan.dto.request.TestPlanShareReportDetailRequest;
import io.metersphere.plan.dto.response.TestPlanCaseExecHistoryResponse;
import io.metersphere.plan.dto.response.TestPlanReportDetailResponse;
import io.metersphere.plan.dto.response.TestPlanShareResponse;
import io.metersphere.plan.service.TestPlanReportService;
@ -163,4 +164,12 @@ public class TestPlanReportShareController {
testPlanReportShareService.validateExpired(shareInfo);
return apiScenarioReportService.getDetail(reportId, stepId);
}
@GetMapping("/detail/functional/case/step/{shareId}/{reportId}")
@Operation(summary = "测试计划-报告-详情-功能用例-执行步骤结果")
public TestPlanCaseExecHistoryResponse getFunctionalExecuteResult(@PathVariable String shareId, @PathVariable String reportId) {
ShareInfo shareInfo = testPlanReportShareService.checkResource(shareId);
testPlanReportShareService.validateExpired(shareInfo);
return testPlanReportService.getFunctionalExecuteResult(reportId);
}
}

View File

@ -14,4 +14,6 @@ public interface ExtTestPlanCaseExecuteHistoryMapper {
List<TestPlanCaseExecHistoryResponse> getCaseExecHistory(@Param("request") TestPlanCaseExecHistoryRequest request);
List<TestPlanCaseExecuteHistory> selectSteps(@Param("testPlanCaseId") String testPlanCaseId, @Param("caseId") String caseId);
TestPlanCaseExecHistoryResponse getSingleExecHistory(@Param("id") String id);
}

View File

@ -37,6 +37,27 @@
tpceh.create_time DESC
</select>
<select id="getSingleExecHistory" resultType="io.metersphere.plan.dto.response.TestPlanCaseExecHistoryResponse">
SELECT
tpceh.id as id,
tpceh.case_id as caseId,
tpceh.status as status,
tpceh.content as content,
tpceh.steps as steps,
tpceh.create_user as createUser,
tpceh.create_time as createTime,
tpceh.notifier as notifier,
u.name AS userName,
ux.avatar AS userLogo,
u.email AS email
FROM
test_plan_case_execute_history tpceh
left JOIN user u ON tpceh.create_user = u.id
left JOIN user_extend ux ON tpceh.create_user = ux.id
WHERE
tpceh.id = #{id}
</select>
<select id="selectSteps" resultType="io.metersphere.plan.domain.TestPlanCaseExecuteHistory">
SELECT
test_plan_case_execute_history.id,

View File

@ -6,6 +6,7 @@ import io.metersphere.plan.constants.AssociateCaseType;
import io.metersphere.plan.domain.*;
import io.metersphere.plan.dto.*;
import io.metersphere.plan.dto.request.*;
import io.metersphere.plan.dto.response.TestPlanCaseExecHistoryResponse;
import io.metersphere.plan.dto.response.TestPlanReportDetailResponse;
import io.metersphere.plan.dto.response.TestPlanReportPageResponse;
import io.metersphere.plan.enums.TestPlanReportAttachmentSourceType;
@ -44,6 +45,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.stream.Collectors;
@ -98,6 +100,8 @@ public class TestPlanReportService {
private BaseUserMapper baseUserMapper;
@Resource
private TestPlanSendNoticeService testPlanSendNoticeService;
@Resource
private ExtTestPlanCaseExecuteHistoryMapper extTestPlanCaseExecuteHistoryMapper;
/**
* 分页查询报告列表
@ -598,6 +602,22 @@ public class TestPlanReportService {
return detailCases;
}
/**
* 返回功能用例执行结果
* @param executeHisId 执行历史ID
* @return 执行结果
*/
public TestPlanCaseExecHistoryResponse getFunctionalExecuteResult(String executeHisId) {
TestPlanCaseExecHistoryResponse singleExecHistory = extTestPlanCaseExecuteHistoryMapper.getSingleExecHistory(executeHisId);
if (singleExecHistory.getContent() != null) {
singleExecHistory.setContentText(new String(singleExecHistory.getContent(), StandardCharsets.UTF_8));
}
if (singleExecHistory.getSteps() != null) {
singleExecHistory.setStepsExecResult(new String(singleExecHistory.getSteps(), StandardCharsets.UTF_8));
}
return singleExecHistory;
}
/**
* 汇总生成的计划报告
*

View File

@ -51,6 +51,7 @@ public class TestPlanReportControllerTests extends BaseTest {
private static final String EDIT_PLAN_REPORT = "/test-plan/report/detail/edit";
private static final String GET_PLAN_REPORT_DETAIL_BUG_PAGE = "/test-plan/report/detail/bug/page";
private static final String GET_PLAN_REPORT_DETAIL_FUNCTIONAL_PAGE = "/test-plan/report/detail/functional/case/page";
private static final String GET_PLAN_REPORT_DETAIL_FUNCTIONAL_RESULT = "/test-plan/report/detail/functional/case/step";
private static final String GET_PLAN_REPORT_DETAIL_API_PAGE = "/test-plan/report/detail/api/case/page";
private static final String GET_PLAN_REPORT_DETAIL_SCENARIO_PAGE = "/test-plan/report/detail/scenario/case/page";
private static final String GET_PLAN_REPORT_DETAIL_PLAN_PAGE = "/test-plan/report/detail/plan/report/page";
@ -65,6 +66,7 @@ public class TestPlanReportControllerTests extends BaseTest {
private static final String GET_SHARE_REPORT_PLAN_LIST = "/test-plan/report/share/detail/plan/report/page";
private static final String GET_SHARE_REPORT_API_REPORT_LIST = "/test-plan/report/share/detail/api-report";
private static final String GET_SHARE_REPORT_SCENARIO_REPORT_LIST = "/test-plan/report/share/detail/scenario-report";
private static final String GET_SHARE_REPORT_DETAIL_FUNCTIONAL_RESULT = "/test-plan/report/share/detail/functional/case/step";
@Autowired
private TestPlanReportMapper testPlanReportMapper;
@ -213,6 +215,8 @@ public class TestPlanReportControllerTests extends BaseTest {
mockMvc.perform(getRequestBuilder(GET_SHARE_REPORT_SCENARIO_REPORT_LIST + "/get/" + GEN_SHARE_ID + "/" + "test" + "/111"))
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk());
this.requestGetWithOk(GET_SHARE_REPORT_DETAIL_FUNCTIONAL_RESULT + "/" + GEN_SHARE_ID + "/execute-his-1");
}
@Test
@ -344,6 +348,13 @@ public class TestPlanReportControllerTests extends BaseTest {
testPlanReportService.summaryGroupReport("test-plan-report-id-9");
}
@Test
@Order(19)
void testGetReportFunctionalExecResult() throws Exception {
this.requestGet(GET_PLAN_REPORT_DETAIL_FUNCTIONAL_RESULT + "/execute-his-1");
this.requestGet(GET_PLAN_REPORT_DETAIL_FUNCTIONAL_RESULT + "/execute-his-2");
}
@Resource
private TestPlanReportSummaryMapper testPlanReportSummaryMapper;
@Resource

View File

@ -42,3 +42,8 @@ INSERT INTO project_application (`project_id`, `type`, `type_value`) VALUES
('100001100001', 'TEST_PLAN_SHARE_REPORT', '1D');
INSERT INTO `share_info`(`id`, `create_time`, `create_user`, `update_time`, `share_type`, `custom_data`, `lang`, `project_id`) VALUES
('share-1', CURRENT_TIMESTAMP, 'admin', CURRENT_TIMESTAMP, 'TEST_PLAN_SHARE_REPORT', 0x31303531363635363936353436383137, 'zh_CN', '100001100001');
-- 功能用例执行信息
INSERT INTO test_plan_case_execute_history (`id`, `test_plan_case_id`, `test_plan_id`, `case_id`, `status`, `content`, `steps`, `deleted`, `notifier`, `create_user`, `create_time`) VALUES
('execute-his-1', 'test-plan-case-id-for-oasis', 'test-plan-id-for-oasis', 'case-id-for-oasis', 'PENDING', null, null, 0, null, 'admin', UNIX_TIMESTAMP()),
('execute-his-2', 'test-plan-case-id-for-oasis', 'test-plan-id-for-oasis', 'case-id-for-oasis', 'PENDING', '1', '1', 0, null, 'admin', UNIX_TIMESTAMP());