fix(测试跟踪): 修复接口调用没有关联可执行用例测试计划执行时没有提示的缺陷

--bug=1015449 --user=王孝刚
[测试计划]github#16371测试计划里只包含功能用例,在页面无法执行,但是调用API可以执行,且可正常生成报告,报告里无任何信息
https://www.tapd.cn/55049933/s/1214486
This commit is contained in:
wxg0103 2022-07-28 14:26:57 +08:00 committed by f2c-ci-robot[bot]
parent e07bd91c7a
commit 9e2caa1916
10 changed files with 66 additions and 15 deletions

View File

@ -0,0 +1,13 @@
package io.metersphere.base.mapper.ext;
import io.metersphere.base.domain.TestPlanUiScenario;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface ExtTestPlanUiScenarioMapper {
List<TestPlanUiScenario> selectByIdsAndStatusIsNotTrash(@Param("ids") List<String> ids);
}

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="io.metersphere.base.mapper.ext.ExtTestPlanUiScenarioMapper">
<select id="selectByIdsAndStatusIsNotTrash" resultType="io.metersphere.base.domain.TestPlanUiScenario">
SELECT
plan.*
FROM
test_plan_ui_scenario plan
INNER JOIN ui_scenario ui ON plan.ui_scenario_id = ui.id
WHERE
(ui.`status` is null OR ui.`status` != 'Trash') AND plan.id IN
<foreach collection="ids" item="v" separator="," open="(" close=")">
#{v}
</foreach>
</select>
</mapper>

View File

@ -189,6 +189,10 @@ public class TestPlanService {
private TestPlanUiScenarioMapper testPlanUiScenarioMapper;
@Resource
private ExtTestPlanUiScenarioCaseMapper extTestPlanUiScenarioCaseMapper;
@Resource
private ExtTestPlanApiScenarioMapper extTestPlanApiScenarioMapper;
@Resource
private ExtTestPlanUiScenarioMapper extTestPlanUiScenarioMapper;
public synchronized TestPlan addTestPlan(AddTestPlanRequest testPlan) {
if (getTestPlanByName(testPlan.getName()).size() > 0) {
@ -1426,6 +1430,7 @@ public class TestPlanService {
* 如果配置了全部用例返回空的数组
* 如果没有则添加对应的状态
* 都没配置就返回 null
*
* @param config
* @return
*/
@ -2058,6 +2063,10 @@ public class TestPlanService {
}
public String runPlan(TestplanRunRequest testplanRunRequest) {
//检查测试计划下有没有可以执行的用例
if (!haveExecCase(testplanRunRequest.getTestPlanId()) || !haveUiCase(testplanRunRequest.getTestPlanId())) {
MSException.throwException(Translator.get("plan_warning"));
}
String envType = testplanRunRequest.getEnvironmentType();
Map<String, String> envMap = testplanRunRequest.getEnvMap();
String environmentGroupId = testplanRunRequest.getEnvironmentGroupId();
@ -2137,16 +2146,14 @@ public class TestPlanService {
if (StringUtils.isBlank(id)) {
return false;
}
TestPlanApiCaseExample apiCaseExample = new TestPlanApiCaseExample();
apiCaseExample.createCriteria().andTestPlanIdEqualTo(id);
List<TestPlanApiCase> testPlanApiCases = testPlanApiCaseMapper.selectByExample(apiCaseExample);
List<String> ids = new ArrayList<>();
ids.add(id);
List<TestPlanApiCase> testPlanApiCases = extTestPlanApiCaseMapper.selectByIdsAndStatusIsNotTrash(ids);
if (!CollectionUtils.isEmpty(testPlanApiCases)) {
return true;
}
TestPlanApiScenarioExample apiScenarioExample = new TestPlanApiScenarioExample();
apiScenarioExample.createCriteria().andTestPlanIdEqualTo(id);
List<TestPlanApiScenario> testPlanApiScenarios = testPlanApiScenarioMapper.selectByExample(apiScenarioExample);
List<TestPlanApiScenario> testPlanApiScenarios = extTestPlanApiScenarioMapper.selectByIdsAndStatusIsNotTrash(ids);
if (!CollectionUtils.isEmpty(testPlanApiScenarios)) {
return true;
}
@ -2295,6 +2302,8 @@ public class TestPlanService {
Map<String, String> executeQueue = new LinkedHashMap<>();
StringBuilder stringBuilder = new StringBuilder();
//检查测试计划下是否有可执行的用例
StringBuilder haveExecCaseBuilder = new StringBuilder();
for (int i = 0; i < planList.size(); i++) {
if (StringUtils.isBlank(planList.get(i).getRunModeConfig())) {
StringBuilder append = stringBuilder.append("请保存[").append(planList.get(i).getName()).append("]的运行配置");
@ -2302,12 +2311,19 @@ public class TestPlanService {
append.append("/");
}
}
if (!haveExecCase(planList.get(i).getId()) || !haveUiCase(planList.get(i).getId())) {
haveExecCaseBuilder.append(planList.get(i).getName()).append("; ");
}
}
if (StringUtils.isNotEmpty(stringBuilder)) {
MSException.throwException(stringBuilder.toString());
}
if (StringUtils.isNotEmpty(haveExecCaseBuilder)) {
MSException.throwException(Translator.get("track_test_plan") + ": " + haveExecCaseBuilder.toString() + ": " + Translator.get("plan_warning"));
}
for (String id : ids) {
TestPlanWithBLOBs testPlan = testPlanMap.get(id);
String planReportId = UUID.randomUUID().toString();
@ -2389,9 +2405,9 @@ public class TestPlanService {
return false;
}
TestPlanUiScenarioExample uiScenarioExample = new TestPlanUiScenarioExample();
uiScenarioExample.createCriteria().andTestPlanIdEqualTo(id);
List<TestPlanUiScenario> testPlanUiScenarios = testPlanUiScenarioMapper.selectByExample(uiScenarioExample);
List<String> ids = new ArrayList<>();
ids.add(id);
List<TestPlanUiScenario> testPlanUiScenarios = extTestPlanUiScenarioMapper.selectByIdsAndStatusIsNotTrash(ids);
return !CollectionUtils.isEmpty(testPlanUiScenarios);
}
}

@ -1 +1 @@
Subproject commit 0c786599f916ed6afc78915f9325457ac52e298b
Subproject commit 1965e5d82cd95cc8ceb8ee5a072acd7380849249

View File

@ -220,8 +220,8 @@ import_xmind_not_found=Test case not found
license_valid_license_error=Authorization authentication failed
test_review_task_notice=Test review task notice
swagger_url_scheduled_import_notification=SwaggerUrl Scheduled import notification
Swagger_parse_error =Swagger parsing failed, please confirm file format is correct!
Swagger_parse_error_with_auth =Swagger parsing failed. Please check whether authentication information is correct or file format is correct!
Swagger_parse_error=Swagger parsing failed, please confirm file format is correct!
Swagger_parse_error_with_auth=Swagger parsing failed. Please check whether authentication information is correct or file format is correct!
test_track.length_less_than=The title is too long, the length must be less than
# check owner
check_owner_project=The current user does not have permission to operate this project
@ -405,3 +405,4 @@ ui_element_already_exists_excel=There are duplicate data in the import file
ui_element_already_exists_data=An element with the same name already exists
serial=Serial
parallel=Parallel
plan_warning=The test plan does not have an associated executable use case

View File

@ -404,3 +404,4 @@ ui_element_already_exists_excel=文件中存在多条相同数据
ui_element_already_exists_data=已经存在同名元素
serial=串行
parallel=并行
plan_warning=测试计划没有关联可执行的用例

View File

@ -403,3 +403,4 @@ ui_element_already_exists_excel=文件中存在多條相同數據
ui_element_already_exists_data=已經存在同名元素
serial=串行
parallel=並行
plan_warning=測試計劃沒有關聯可執行的用例

@ -1 +1 @@
Subproject commit 0b367ee1d426d6bbbfe935d64c5680bcf2db704c
Subproject commit 311095fddb07b11b034b139152a59810cd5ed7d1

View File

@ -2154,7 +2154,7 @@ export default {
batch_copy: '批量复制',
batch_add_public: '批量添加到公共用例库',
batch_link_demand: '批量关联需求',
public_warning: '未开启公共用例配置',
public_warning: '未开启公共用例配置',
generate_dependencies: '生成依赖关系',
generate_dependencies_warning: '为了更好的体验,建议勾选一百条以下的数据',
batch_unlink: '批量取消关联',

View File

@ -2149,7 +2149,7 @@ export default {
batch_copy: '批量復製',
batch_add_public: '批量添加到公共用例庫',
batch_link_demand: '批量關聯需求',
public_warning: '未開啟公共用例配置',
public_warning: '未開啟公共用例配置',
generate_dependencies: '生成依賴關系',
generate_dependencies_warning: '為了更好的體驗,建議勾選一百條以下的數據',
batch_unlink: '批量取消關聯',