fix(测试跟踪): 测试计划实时报告显示执行了的用例的环境

测试计划实时报告显示执行了的用例的环境
This commit is contained in:
song-tianyang 2022-07-14 14:26:02 +08:00 committed by TIanyang
parent bed0ed6faf
commit e4d1cfa9a2
13 changed files with 659 additions and 470 deletions

View File

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.parser.Feature;
import io.metersphere.api.dto.EnvironmentType;
import io.metersphere.api.dto.RunModeConfigWithEnvironmentDTO;
import io.metersphere.api.dto.ScenarioEnv;
import io.metersphere.api.dto.automation.ApiScenarioDTO;
import io.metersphere.api.dto.automation.RunScenarioRequest;
@ -22,6 +23,7 @@ import io.metersphere.commons.constants.MsTestElementConstants;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.dto.RunModeConfigDTO;
import io.metersphere.plugin.core.MsTestElement;
import io.metersphere.service.EnvironmentGroupProjectService;
import io.metersphere.service.ProjectService;
@ -471,4 +473,74 @@ public class ApiScenarioEnvService {
}
return returnMap;
}
public Map<String, List<String>> selectProjectEnvMapByTestPlanScenarioIds(List<String> resourceIds) {
Map<String, List<String>> returnMap = new LinkedHashMap<>();
if (CollectionUtils.isNotEmpty(resourceIds)) {
List<String> reportEnvConfList = testPlanApiScenarioMapper.selectReportEnvConfByResourceIds(resourceIds);
reportEnvConfList.forEach(envConf -> {
LinkedHashMap<String, List<String>> projectEnvMap = this.getProjectEnvMapByEnvConfig(envConf);
for (Map.Entry<String, List<String>> entry : projectEnvMap.entrySet()) {
String projectName = entry.getKey();
List<String> envNameList = entry.getValue();
if (StringUtils.isEmpty(projectName) || CollectionUtils.isEmpty(envNameList)) {
continue;
}
if (returnMap.containsKey(projectName)) {
envNameList.forEach(envName -> {
if (!returnMap.get(projectName).contains(envName)) {
returnMap.get(projectName).add(envName);
}
});
} else {
returnMap.put(projectName, envNameList);
}
}
});
}
return returnMap;
}
public LinkedHashMap<String, List<String>> getProjectEnvMapByEnvConfig(String envConfig) {
LinkedHashMap<String, List<String>> returnMap = new LinkedHashMap<>();
//运行设置中选择的环境信息批量执行时在前台选择了执行信息
Map<String, String> envMapByRunConfig = null;
//执行时选择的环境信息 一般在集合报告中会记录
Map<String, List<String>> envMapByExecution = null;
try {
JSONObject jsonObject = JSONObject.parseObject(envConfig);
if (jsonObject.containsKey("executionEnvironmentMap")) {
RunModeConfigWithEnvironmentDTO configWithEnvironment = JSONObject.parseObject(envConfig, RunModeConfigWithEnvironmentDTO.class);
if (MapUtils.isNotEmpty(configWithEnvironment.getExecutionEnvironmentMap())) {
envMapByExecution = configWithEnvironment.getExecutionEnvironmentMap();
} else {
envMapByRunConfig = configWithEnvironment.getEnvMap();
}
} else {
RunModeConfigDTO config = JSONObject.parseObject(envConfig, RunModeConfigDTO.class);
envMapByRunConfig = config.getEnvMap();
}
} catch (Exception e) {
LogUtil.error("解析RunModeConfig失败!参数:" + envConfig, e);
}
returnMap.putAll(this.selectProjectNameAndEnvName(envMapByExecution));
if (MapUtils.isNotEmpty(envMapByRunConfig)) {
for (Map.Entry<String, String> entry : envMapByRunConfig.entrySet()) {
String projectId = entry.getKey();
String envId = entry.getValue();
String projectName = projectService.selectNameById(projectId);
String envName = apiTestEnvironmentService.selectNameById(envId);
if (StringUtils.isNoneEmpty(projectName, envName)) {
returnMap.put(projectName, new ArrayList<>() {{
this.add(envName);
}});
}
}
}
return returnMap;
}
}

View File

@ -523,4 +523,12 @@ public class ApiDefinitionExecResultService {
});
return list;
}
public List<ApiDefinitionExecResultWithBLOBs> selectByResourceIdsAndMaxCreateTime(List<String> resourceIds) {
if (CollectionUtils.isNotEmpty(resourceIds)) {
return extApiDefinitionExecResultMapper.selectByResourceIdsAndMaxCreateTime(resourceIds);
} else {
return new ArrayList<>();
}
}
}

View File

@ -156,6 +156,9 @@ public class ApiDefinitionService {
private ApiModuleService apiModuleService;
@Resource
private ApiTestEnvironmentService apiTestEnvironmentService;
@Lazy
@Resource
private ProjectService projectService;
private ThreadLocal<Long> currentApiOrder = new ThreadLocal<>();
private ThreadLocal<Long> currentApiCaseOrder = new ThreadLocal<>();
@ -1344,6 +1347,27 @@ public class ApiDefinitionService {
return reportResult;
}
public Map<String, List<String>> getProjectEnvNameByEnvConfig(String projectId, String envConfig) {
Map<String, List<String>> returnMap = new HashMap<>();
RunModeConfigDTO runModeConfigDTO = null;
try {
runModeConfigDTO = JSONObject.parseObject(envConfig, RunModeConfigDTO.class);
} catch (Exception e) {
LogUtil.error("解析" + envConfig + "为RunModeConfigDTO时失败", e);
}
if (StringUtils.isNotEmpty(projectId) && runModeConfigDTO != null && MapUtils.isNotEmpty(runModeConfigDTO.getEnvMap())) {
String envId = runModeConfigDTO.getEnvMap().get(projectId);
String envName = apiTestEnvironmentService.selectNameById(envId);
String projectName = projectService.selectNameById(projectId);
if (StringUtils.isNoneEmpty(envName, projectName)) {
returnMap.put(projectName, new ArrayList<>() {{
this.add(envName);
}});
}
}
return returnMap;
}
public String getEnvNameByEnvConfig(String projectId, String envConfig) {
String envName = null;
RunModeConfigDTO runModeConfigDTO = null;

View File

@ -4,7 +4,10 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.parser.Feature;
import io.metersphere.api.dto.*;
import io.metersphere.api.dto.ApiScenarioReportBaseInfoDTO;
import io.metersphere.api.dto.ApiScenarioReportDTO;
import io.metersphere.api.dto.RequestResultExpandDTO;
import io.metersphere.api.dto.StepTreeDTO;
import io.metersphere.api.exec.scenario.ApiScenarioEnvService;
import io.metersphere.api.exec.utils.ResultParseUtil;
import io.metersphere.api.service.vo.ApiDefinitionExecResultVo;
@ -20,7 +23,6 @@ import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.constants.RunModeConstants;
import io.metersphere.dto.RequestResult;
import io.metersphere.dto.RunModeConfigDTO;
import io.metersphere.service.ProjectService;
import io.metersphere.utils.LoggerUtil;
import org.apache.commons.collections.CollectionUtils;
@ -545,48 +547,12 @@ public class ApiScenarioReportStructureService {
public void initProjectEnvironmentByEnvConfig(ApiScenarioReportDTO dto, String envConfig) {
if (StringUtils.isNotEmpty(envConfig)) {
//运行设置中选择的环境信息批量执行时在前台选择了执行信息
Map<String, String> envMapByRunConfig = null;
//执行时选择的环境信息 一般在集合报告中会记录
Map<String, List<String>> envMapByExecution = null;
try {
JSONObject jsonObject = JSONObject.parseObject(envConfig);
if (jsonObject.containsKey("executionEnvironmentMap")) {
RunModeConfigWithEnvironmentDTO configWithEnvironment = JSONObject.parseObject(envConfig, RunModeConfigWithEnvironmentDTO.class);
if (MapUtils.isNotEmpty(configWithEnvironment.getExecutionEnvironmentMap())) {
envMapByExecution = configWithEnvironment.getExecutionEnvironmentMap();
} else {
envMapByRunConfig = configWithEnvironment.getEnvMap();
}
} else {
RunModeConfigDTO config = JSONObject.parseObject(envConfig, RunModeConfigDTO.class);
envMapByRunConfig = config.getEnvMap();
}
} catch (Exception e) {
LogUtil.error("解析RunModeConfig失败!参数:" + envConfig, e);
}
LinkedHashMap<String, List<String>> projectEnvMap = apiScenarioEnvService.selectProjectNameAndEnvName(envMapByExecution);
if (MapUtils.isNotEmpty(envMapByRunConfig)) {
for (Map.Entry<String, String> entry : envMapByRunConfig.entrySet()) {
String projectId = entry.getKey();
String envId = entry.getValue();
String projectName = projectService.selectNameById(projectId);
String envName = apiTestEnvironmentService.selectNameById(envId);
if (StringUtils.isNoneEmpty(projectName, envName)) {
projectEnvMap.put(projectName, new ArrayList<>() {{
this.add(envName);
}});
}
}
LinkedHashMap<String, List<String>> projectEnvMap = apiScenarioEnvService.getProjectEnvMapByEnvConfig(envConfig);
if (MapUtils.isNotEmpty(projectEnvMap)) {
dto.setProjectEnvMap(projectEnvMap);
}
}
}
}
private ApiScenarioReportDTO getReport(String reportId, boolean selectContent) {

View File

@ -2,9 +2,10 @@ package io.metersphere.base.mapper;
import io.metersphere.base.domain.TestPlanApiScenario;
import io.metersphere.base.domain.TestPlanApiScenarioExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface TestPlanApiScenarioMapper {
long countByExample(TestPlanApiScenarioExample example);
@ -33,4 +34,6 @@ public interface TestPlanApiScenarioMapper {
int updateByPrimaryKeyWithBLOBs(TestPlanApiScenario record);
int updateByPrimaryKey(TestPlanApiScenario record);
List<String> selectReportEnvConfByResourceIds(@Param("ids") List<String> resourceIds);
}

View File

@ -2,22 +2,22 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="io.metersphere.base.mapper.TestPlanApiScenarioMapper">
<resultMap id="BaseResultMap" type="io.metersphere.base.domain.TestPlanApiScenario">
<id column="id" jdbcType="VARCHAR" property="id" />
<result column="test_plan_id" jdbcType="VARCHAR" property="testPlanId" />
<result column="api_scenario_id" jdbcType="VARCHAR" property="apiScenarioId" />
<result column="status" jdbcType="VARCHAR" property="status" />
<result column="create_time" jdbcType="BIGINT" property="createTime" />
<result column="update_time" jdbcType="BIGINT" property="updateTime" />
<result column="pass_rate" jdbcType="VARCHAR" property="passRate" />
<result column="last_result" jdbcType="VARCHAR" property="lastResult" />
<result column="report_id" jdbcType="VARCHAR" property="reportId" />
<result column="create_user" jdbcType="VARCHAR" property="createUser" />
<result column="order" jdbcType="BIGINT" property="order" />
<result column="environment_type" jdbcType="VARCHAR" property="environmentType" />
<result column="environment_group_id" jdbcType="VARCHAR" property="environmentGroupId" />
<id column="id" jdbcType="VARCHAR" property="id"/>
<result column="test_plan_id" jdbcType="VARCHAR" property="testPlanId"/>
<result column="api_scenario_id" jdbcType="VARCHAR" property="apiScenarioId"/>
<result column="status" jdbcType="VARCHAR" property="status"/>
<result column="create_time" jdbcType="BIGINT" property="createTime"/>
<result column="update_time" jdbcType="BIGINT" property="updateTime"/>
<result column="pass_rate" jdbcType="VARCHAR" property="passRate"/>
<result column="last_result" jdbcType="VARCHAR" property="lastResult"/>
<result column="report_id" jdbcType="VARCHAR" property="reportId"/>
<result column="create_user" jdbcType="VARCHAR" property="createUser"/>
<result column="order" jdbcType="BIGINT" property="order"/>
<result column="environment_type" jdbcType="VARCHAR" property="environmentType"/>
<result column="environment_group_id" jdbcType="VARCHAR" property="environmentGroupId"/>
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.TestPlanApiScenario">
<result column="environment" jdbcType="LONGVARCHAR" property="environment" />
<result column="environment" jdbcType="LONGVARCHAR" property="environment"/>
</resultMap>
<sql id="Example_Where_Clause">
<where>
@ -37,7 +37,8 @@
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
<foreach close=")" collection="criterion.value" item="listItem" open="("
separator=",">
#{listItem}
</foreach>
</when>
@ -66,7 +67,8 @@
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
<foreach close=")" collection="criterion.value" item="listItem" open="("
separator=",">
#{listItem}
</foreach>
</when>
@ -78,37 +80,40 @@
</where>
</sql>
<sql id="Base_Column_List">
id, test_plan_id, api_scenario_id, `status`, create_time, update_time, pass_rate,
id
, test_plan_id, api_scenario_id, `status`, create_time, update_time, pass_rate,
last_result, report_id, create_user, `order`, environment_type, environment_group_id
</sql>
<sql id="Blob_Column_List">
environment
</sql>
<select id="selectByExampleWithBLOBs" parameterType="io.metersphere.base.domain.TestPlanApiScenarioExample" resultMap="ResultMapWithBLOBs">
<select id="selectByExampleWithBLOBs" parameterType="io.metersphere.base.domain.TestPlanApiScenarioExample"
resultMap="ResultMapWithBLOBs">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
<include refid="Base_Column_List"/>
,
<include refid="Blob_Column_List" />
<include refid="Blob_Column_List"/>
from test_plan_api_scenario
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
<include refid="Example_Where_Clause"/>
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByExample" parameterType="io.metersphere.base.domain.TestPlanApiScenarioExample" resultMap="BaseResultMap">
<select id="selectByExample" parameterType="io.metersphere.base.domain.TestPlanApiScenarioExample"
resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
<include refid="Base_Column_List"/>
from test_plan_api_scenario
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
<include refid="Example_Where_Clause"/>
</if>
<if test="orderByClause != null">
order by ${orderByClause}
@ -116,20 +121,21 @@
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="ResultMapWithBLOBs">
select
<include refid="Base_Column_List" />
<include refid="Base_Column_List"/>
,
<include refid="Blob_Column_List" />
<include refid="Blob_Column_List"/>
from test_plan_api_scenario
where id = #{id,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from test_plan_api_scenario
delete
from test_plan_api_scenario
where id = #{id,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="io.metersphere.base.domain.TestPlanApiScenarioExample">
delete from test_plan_api_scenario
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
<include refid="Example_Where_Clause"/>
</if>
</delete>
<insert id="insert" parameterType="io.metersphere.base.domain.TestPlanApiScenario">
@ -235,12 +241,22 @@
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.base.domain.TestPlanApiScenarioExample" resultType="java.lang.Long">
<select id="countByExample" parameterType="io.metersphere.base.domain.TestPlanApiScenarioExample"
resultType="java.lang.Long">
select count(*) from test_plan_api_scenario
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
<include refid="Example_Where_Clause"/>
</if>
</select>
<select id="selectReportEnvConfByResourceIds" resultType="java.lang.String">
SELECT env_config FROM api_scenario_report WHERE id IN (
select report_id FROM test_plan_api_scenario WHERE id IN
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
)
</select>
<update id="updateByExampleSelective" parameterType="map">
update test_plan_api_scenario
<set>
@ -288,7 +304,7 @@
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
<include refid="Update_By_Example_Where_Clause"/>
</if>
</update>
<update id="updateByExampleWithBLOBs" parameterType="map">
@ -308,7 +324,7 @@
environment_group_id = #{record.environmentGroupId,jdbcType=VARCHAR},
environment = #{record.environment,jdbcType=LONGVARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
<include refid="Update_By_Example_Where_Clause"/>
</if>
</update>
<update id="updateByExample" parameterType="map">
@ -327,7 +343,7 @@
environment_type = #{record.environmentType,jdbcType=VARCHAR},
environment_group_id = #{record.environmentGroupId,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
<include refid="Update_By_Example_Where_Clause"/>
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.base.domain.TestPlanApiScenario">

View File

@ -56,4 +56,6 @@ public interface ExtApiDefinitionExecResultMapper {
List<ApiDefinitionExecResultWithBLOBs> selectRerunResult(@Param("reportId") String reportId);
List<String> selectByProjectIdAndLessThanTime(@Param("projectId") String projectId, @Param("time") long time);
List<ApiDefinitionExecResultWithBLOBs> selectByResourceIdsAndMaxCreateTime(@Param("ids") List<String> resourceIds);
}

View File

@ -416,6 +416,17 @@
</foreach>
</update>
<select id="selectByResourceIdsAndMaxCreateTime"
resultType="io.metersphere.base.domain.ApiDefinitionExecResultWithBLOBs">
SELECT resource_id,max(create_time) AS create_time, id, env_config, project_id FROM api_definition_exec_result
WHERE
resource_id IN
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
GROUP BY resource_id;
</select>
<select id="findByProjectIds" resultType="io.metersphere.base.domain.ApiDefinitionExecResult"
parameterType="java.lang.String">
select actuator ,id from api_definition_exec_result where status in ("running","starting","waiting") and
@ -431,10 +442,8 @@
</select>
<select id="selectRerunResult" resultType="io.metersphere.base.domain.ApiDefinitionExecResultWithBLOBs">
SELECT
r.*
FROM
api_definition_exec_result r
SELECT r.*
FROM api_definition_exec_result r
INNER JOIN api_test_case c ON r.resource_id = c.id
AND c.`status` != 'Trash'
WHERE
@ -444,7 +453,10 @@
r.create_time ASC
</select>
<select id="selectByProjectIdAndLessThanTime" resultType="java.lang.String">
select id from api_definition_exec_result where project_id = #{projectId} and create_time &lt; #{time}
select id
from api_definition_exec_result
where project_id = #{projectId}
and create_time &lt; #{time}
</select>
</mapper>

View File

@ -10,7 +10,9 @@ import io.metersphere.api.dto.definition.ApiTestCaseRequest;
import io.metersphere.api.dto.definition.BatchRunDefinitionRequest;
import io.metersphere.api.dto.definition.TestPlanApiCaseDTO;
import io.metersphere.api.exec.api.ApiCaseExecuteService;
import io.metersphere.api.exec.scenario.ApiScenarioEnvService;
import io.metersphere.api.service.ApiDefinitionExecResultService;
import io.metersphere.api.service.ApiDefinitionService;
import io.metersphere.api.service.ApiTestCaseService;
import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.ApiTestCaseMapper;
@ -29,6 +31,7 @@ import io.metersphere.track.dto.TestCaseReportStatusResultDTO;
import io.metersphere.track.dto.TestPlanApiResultReportDTO;
import io.metersphere.track.dto.TestPlanSimpleReportDTO;
import io.metersphere.track.request.testcase.TestPlanApiCaseBatchRequest;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession;
@ -69,6 +72,11 @@ public class TestPlanApiCaseService {
private TestPlanService testPlanService;
@Resource
private EnvironmentGroupProjectService environmentGroupProjectService;
@Resource
private ApiDefinitionService apiDefinitionService;
@Resource
private ApiScenarioEnvService apiScenarioEnvService;
public TestPlanApiCase getInfo(String caseId, String testPlanId) {
TestPlanApiCaseExample example = new TestPlanApiCaseExample();
@ -368,9 +376,66 @@ public class TestPlanApiCaseService {
return extTestPlanApiCaseMapper.getApiTestCaseById(testPlanApiCaseId);
}
/**
* 计算测试计划中接口用例的相关数据
*
* @param planId
* @param report
* @return 接口用例的最新执行报告
*/
public void calculatePlanReport(String planId, TestPlanSimpleReportDTO report) {
List<PlanReportCaseDTO> planReportCaseDTOS = extTestPlanApiCaseMapper.selectForPlanReport(planId);
//计算测试计划中接口用例的相关数据
calculatePlanReport(report, planReportCaseDTOS);
//记录接口用例的运行环境信息
List<String> idList = planReportCaseDTOS.stream().map(PlanReportCaseDTO::getId).collect(Collectors.toList());
this.initProjectEnvironment(report, idList, "ApiCase");
}
/**
* 初始化项目环境信息
*
* @param report
* @param resourceIds 资源ID
* @param resourceType 资源类型 ApiCase/Scenario
*/
public void initProjectEnvironment(TestPlanSimpleReportDTO report, List<String> resourceIds, String resourceType) {
if (!CollectionUtils.isEmpty(resourceIds)) {
if (StringUtils.equalsIgnoreCase("ApiCase", resourceType)) {
List<ApiDefinitionExecResultWithBLOBs> execResults = apiDefinitionExecResultService.selectByResourceIdsAndMaxCreateTime(resourceIds);
execResults.forEach(item -> {
String envConf = item.getEnvConfig();
String projectId = item.getProjectId();
Map<String, List<String>> projectEnvMap = apiDefinitionService.getProjectEnvNameByEnvConfig(projectId, envConf);
this.setProjectEnvMap(report, projectEnvMap);
});
} else if (StringUtils.equalsIgnoreCase("Scenario", resourceType)) {
Map<String, List<String>> projectEnvMap = apiScenarioEnvService.selectProjectEnvMapByTestPlanScenarioIds(resourceIds);
this.setProjectEnvMap(report, projectEnvMap);
}
}
}
private void setProjectEnvMap(TestPlanSimpleReportDTO report, Map<String, List<String>> projectEnvMap) {
if (report != null && MapUtils.isNotEmpty(projectEnvMap)) {
if (report.getProjectEnvMap() == null) {
report.setProjectEnvMap(new LinkedHashMap<>());
}
for (Map.Entry<String, List<String>> entry : projectEnvMap.entrySet()) {
String projectName = entry.getKey();
List<String> envNameList = entry.getValue();
if (report.getProjectEnvMap().containsKey(projectName)) {
envNameList.forEach(envName -> {
if (!report.getProjectEnvMap().get(projectName).contains(envName)) {
report.getProjectEnvMap().get(projectName).add(envName);
}
});
} else {
report.getProjectEnvMap().put(projectName, envNameList);
}
}
}
}
public void calculatePlanReport(List<String> apiReportIds, TestPlanSimpleReportDTO report) {

View File

@ -72,6 +72,8 @@ public class TestPlanScenarioCaseService {
private TestPlanService testPlanService;
@Resource
private ProjectApplicationService projectApplicationService;
@Resource
private TestPlanApiCaseService testPlanApiCaseService;
public List<ApiScenarioDTO> list(TestPlanScenarioRequest request) {
request.setProjectId(null);
@ -96,15 +98,15 @@ public class TestPlanScenarioCaseService {
apiTestCases.forEach(item -> {
Project project = projectMap.get(item.getProjectId());
if(project != null){
if (project != null) {
ProjectConfig config = projectApplicationService.getSpecificTypeValue(project.getId(), ProjectApplicationType.SCENARIO_CUSTOM_NUM.name());
boolean custom = config.getScenarioCustomNum();
if (custom) {
item.setCustomNum(item.getCustomNum());
}else {
} else {
item.setCustomNum(item.getNum().toString());
}
}else {
} else {
item.setCustomNum(item.getNum().toString());
}
});
@ -492,6 +494,9 @@ public class TestPlanScenarioCaseService {
public void calculatePlanReport(String planId, TestPlanSimpleReportDTO report) {
List<PlanReportCaseDTO> planReportCaseDTOS = extTestPlanScenarioCaseMapper.selectForPlanReport(planId);
calculatePlanReport(report, planReportCaseDTOS);
//记录接口用例的运行环境信息
List<String> idList = planReportCaseDTOS.stream().map(PlanReportCaseDTO::getId).collect(Collectors.toList());
testPlanApiCaseService.initProjectEnvironment(report, idList, "Scenario");
}
public void calculatePlanReport(List<String> reportIds, TestPlanSimpleReportDTO report) {
@ -499,7 +504,7 @@ public class TestPlanScenarioCaseService {
calculatePlanReport(report, planReportCaseDTOS);
}
public void calculatePlanReportByScenarioList(List<TestPlanFailureScenarioDTO> scenarioList,TestPlanSimpleReportDTO report){
public void calculatePlanReportByScenarioList(List<TestPlanFailureScenarioDTO> scenarioList, TestPlanSimpleReportDTO report) {
List<PlanReportCaseDTO> planReportCaseDTOS = new ArrayList<>();
for (TestPlanFailureScenarioDTO scenario : scenarioList) {
PlanReportCaseDTO dto = new PlanReportCaseDTO();
@ -545,7 +550,7 @@ public class TestPlanScenarioCaseService {
private void calculateScenarioResultDTO(PlanReportCaseDTO item,
TestPlanScenarioStepCountDTO stepCount) {
if (StringUtils.isNotBlank(item.getReportId())) {
APIScenarioReportResult apiScenarioReportResult = apiScenarioReportService.get(item.getReportId(),false);
APIScenarioReportResult apiScenarioReportResult = apiScenarioReportService.get(item.getReportId(), false);
if (apiScenarioReportResult != null) {
String content = apiScenarioReportResult.getContent();
if (StringUtils.isNotBlank(content)) {

View File

@ -60,7 +60,8 @@
</template>
<template v-slot:button v-if="!ifFromVariableAdvance">
<el-tooltip :content="$t('api_test.run')" placement="top" v-if="!loading">
<el-button :disabled="!request.enable" @click="run" icon="el-icon-video-play" class="ms-btn" size="mini" circle/>
<el-button :disabled="!request.enable" @click="run" icon="el-icon-video-play" class="ms-btn" size="mini"
circle/>
</el-tooltip>
<el-tooltip :content="$t('report.stop_btn')" placement="top" :enterable="false" v-else>
<el-button @click.once="stop" size="mini" style="color:white;padding: 0 0.1px;width: 24px;height: 24px;"
@ -167,7 +168,7 @@
</template>
<script>
import {getUUID, getCurrentProjectID, getCurrentWorkspaceId} from "@/common/js/utils";
import {getCurrentProjectID, getCurrentWorkspaceId, getUUID} from "@/common/js/utils";
import {getUrl} from "@/business/components/api/automation/scenario/component/urlhelper";
const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/);
@ -645,7 +646,7 @@ export default {
resource.protocol = 'DUBBO'
}
let definitionData = this.$router.resolve({
name: 'ApiDefinition',
name: 'ApiDefinitionWithQuery',
params: {
redirectID: getUUID(),
dataType: "api",

View File

@ -32,9 +32,14 @@
</template>
<template v-slot:behindHeaderLeft>
<el-tag size="small" class="ms-tag" v-if="scenario.referenced==='Deleted'" type="danger">{{ $t('api_test.automation.reference_deleted') }}</el-tag>
<el-tag size="small" class="ms-tag" v-if="scenario.referenced==='Deleted'" type="danger">
{{ $t('api_test.automation.reference_deleted') }}
</el-tag>
<el-tag size="small" class="ms-tag" v-if="scenario.referenced==='Copy'">{{ $t('commons.copy') }}</el-tag>
<el-tag size="small" class="ms-tag" v-if="scenario.referenced==='REF'">{{ $t('api_test.scenario.reference') }}</el-tag>
<el-tag size="small" class="ms-tag" v-if="scenario.referenced==='REF'">{{
$t('api_test.scenario.reference')
}}
</el-tag>
<span class="ms-tag ms-step-name-api">{{ getProjectName(scenario.projectId) }}</span>
</template>
<template v-slot:debugStepCode>
@ -42,16 +47,19 @@
<i class="el-icon-loading" style="font-size: 16px"/>
{{ $t('commons.testing') }}
</span>
<span class="ms-step-debug-code" :class="node.data.code ==='error'?'ms-req-error':'ms-req-success'" v-if="!loading && node.data.debug && !node.data.testing">
<span class="ms-step-debug-code" :class="node.data.code ==='error'?'ms-req-error':'ms-req-success'"
v-if="!loading && node.data.debug && !node.data.testing">
{{ getCode() }}
</span>
</template>
<template v-slot:button v-if="!ifFromVariableAdvance">
<el-tooltip :content="$t('api_test.run')" placement="top" v-if="!scenario.run">
<el-button :disabled="!scenario.enable" @click="run" icon="el-icon-video-play" style="padding: 5px" class="ms-btn" size="mini" circle/>
<el-button :disabled="!scenario.enable" @click="run" icon="el-icon-video-play" style="padding: 5px"
class="ms-btn" size="mini" circle/>
</el-tooltip>
<el-tooltip :content="$t('report.stop_btn')" placement="top" :enterable="false" v-else>
<el-button :disabled="!scenario.enable" @click.once="stop" size="mini" style="color:white;padding: 0 0.1px;width: 24px;height: 24px;" class="stop-btn" circle>
<el-button :disabled="!scenario.enable" @click.once="stop" size="mini"
style="color:white;padding: 0 0.1px;width: 24px;height: 24px;" class="stop-btn" circle>
<div style="transform: scale(0.66)">
<span style="margin-left: -4.5px;font-weight: bold;">STOP</span>
</div>
@ -286,8 +294,14 @@ export default {
},
gotoTurn(resource, workspaceId, isTurnSpace) {
let automationData = this.$router.resolve({
name: 'ApiAutomation',
params: {redirectID: getUUID(), dataType: "scenario", dataSelectRange: 'edit:' + resource.id, projectId: resource.projectId, workspaceId: workspaceId}
name: 'ApiAutomationWithQuery',
params: {
redirectID: getUUID(),
dataType: "scenario",
dataSelectRange: 'edit:' + resource.id,
projectId: resource.projectId,
workspaceId: workspaceId
}
});
if (isTurnSpace) {
window.open(automationData.href, '_blank');

View File

@ -6,7 +6,7 @@
</el-form-item>
<el-row type="flex" class="select-time"
v-if="report.envGroupName || report.projectEnvMap">
<span> {{ $t('commons.environment') + ':' }} </span>
<el-form-item :label="$t('commons.environment') + ':'" style="width: 100%">
<div v-if="report.envGroupName" style="margin-left: 12px">
<ms-tag type="danger" :content="$t('commons.group')"></ms-tag>
{{ report.envGroupName }}
@ -18,6 +18,7 @@
style="margin-left: 2px"/>
</div>
</div>
</el-form-item>
</el-row>
<el-row type="flex" justify="space-between" class="select-time">
<el-col :span="8">