fix(测试计划): 修复测试计划状态不准确
This commit is contained in:
parent
c26e7aa314
commit
4c2002f8ff
|
@ -11,4 +11,5 @@ public interface ExtTestPlanLoadCaseMapper {
|
|||
List<String> selectIdsNotInPlan(@Param("projectId") String projectId, @Param("planId") String planId);
|
||||
List<TestPlanLoadCaseDTO> selectTestPlanLoadCaseList(@Param("request") LoadCaseRequest request);
|
||||
void updateCaseStatus(@Param("reportId") String reportId, @Param("status") String status);
|
||||
List<String> getStatusByTestPlanId(@Param("planId") String planId);
|
||||
}
|
||||
|
|
|
@ -62,4 +62,7 @@
|
|||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
<select id="getStatusByTestPlanId" resultType="java.lang.String">
|
||||
select status from test_plan_load_case tplc where tplc.test_plan_id = #{planId}
|
||||
</select>
|
||||
</mapper>
|
|
@ -19,10 +19,7 @@ import io.metersphere.api.jmeter.JMeterService;
|
|||
import io.metersphere.api.service.ApiAutomationService;
|
||||
import io.metersphere.base.domain.*;
|
||||
import io.metersphere.base.mapper.*;
|
||||
import io.metersphere.base.mapper.ext.ExtApiScenarioMapper;
|
||||
import io.metersphere.base.mapper.ext.ExtTestCaseMapper;
|
||||
import io.metersphere.base.mapper.ext.ExtTestPlanMapper;
|
||||
import io.metersphere.base.mapper.ext.ExtTestPlanTestCaseMapper;
|
||||
import io.metersphere.base.mapper.ext.*;
|
||||
import io.metersphere.commons.constants.*;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.commons.user.SessionUser;
|
||||
|
@ -103,6 +100,10 @@ public class TestPlanService {
|
|||
private JMeterService jMeterService;
|
||||
@Resource
|
||||
private ApiAutomationService apiAutomationService;
|
||||
@Resource
|
||||
private ExtTestPlanApiCaseMapper extTestPlanApiCaseMapper;
|
||||
@Resource
|
||||
private ExtTestPlanLoadCaseMapper extTestPlanLoadCaseMapper;
|
||||
|
||||
public synchronized void addTestPlan(AddTestPlanRequest testPlan) {
|
||||
if (getTestPlanByName(testPlan.getName()).size() > 0) {
|
||||
|
@ -550,18 +551,10 @@ public class TestPlanService {
|
|||
}
|
||||
|
||||
public void editTestPlanStatus(String planId) {
|
||||
List<String> statusList = extTestPlanTestCaseMapper.getStatusByPlanId(planId);
|
||||
TestPlan testPlan = new TestPlan();
|
||||
testPlan.setId(planId);
|
||||
for (String status : statusList) {
|
||||
if (StringUtils.equals(status, TestPlanTestCaseStatus.Prepare.name())
|
||||
|| StringUtils.equals(status, TestPlanTestCaseStatus.Underway.name())) {
|
||||
testPlan.setStatus(TestPlanStatus.Underway.name());
|
||||
testPlanMapper.updateByPrimaryKeySelective(testPlan);
|
||||
return;
|
||||
}
|
||||
}
|
||||
testPlan.setStatus(TestPlanStatus.Completed.name());
|
||||
String status = calcTestPlanStatus(planId);
|
||||
testPlan.setStatus(status);
|
||||
testPlanMapper.updateByPrimaryKeySelective(testPlan);
|
||||
TestPlan testPlans = getTestPlan(planId);
|
||||
List<String> userIds = new ArrayList<>();
|
||||
|
@ -590,6 +583,36 @@ public class TestPlanService {
|
|||
|
||||
}
|
||||
|
||||
|
||||
private String calcTestPlanStatus(String planId) {
|
||||
// test-plan-functional-case status
|
||||
List<String> funcStatusList = extTestPlanTestCaseMapper.getStatusByPlanId(planId);
|
||||
for (String funcStatus : funcStatusList) {
|
||||
if (StringUtils.equals(funcStatus, TestPlanTestCaseStatus.Prepare.name())
|
||||
|| StringUtils.equals(funcStatus, TestPlanTestCaseStatus.Underway.name())) {
|
||||
return TestPlanStatus.Underway.name();
|
||||
}
|
||||
}
|
||||
|
||||
// test-plan-api-case status
|
||||
List<String> apiStatusList = extTestPlanApiCaseMapper.getStatusByTestPlanId(planId);
|
||||
for (String apiStatus : apiStatusList) {
|
||||
if (apiStatus == null) {
|
||||
return TestPlanStatus.Underway.name();
|
||||
}
|
||||
}
|
||||
|
||||
// test-plan-load-case status
|
||||
List<String> loadStatusList = extTestPlanLoadCaseMapper.getStatusByTestPlanId(planId);
|
||||
for (String loadStatus : loadStatusList) {
|
||||
if (loadStatus == null) {
|
||||
return TestPlanStatus.Underway.name();
|
||||
}
|
||||
}
|
||||
|
||||
return TestPlanStatus.Completed.name();
|
||||
}
|
||||
|
||||
public String getProjectNameByPlanId(String testPlanId) {
|
||||
List<String> projectIds = testPlanProjectService.getProjectIdsByPlanId(testPlanId);
|
||||
ProjectExample projectExample = new ProjectExample();
|
||||
|
|
|
@ -75,6 +75,9 @@
|
|||
<el-tag size="mini" type="success" v-else-if="row.caseStatus === 'success'">
|
||||
{{ row.caseStatus }}
|
||||
</el-tag>
|
||||
<el-tag size="mini" v-else-if="row.caseStatus === 'run'">
|
||||
{{ row.caseStatus }}
|
||||
</el-tag>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
@ -264,17 +267,22 @@ export default {
|
|||
title: loadCase.caseName,
|
||||
message: this.$t('test_track.plan.load_case.exec').toString()
|
||||
});
|
||||
this.initTable();
|
||||
this.updateStatus(loadCase, 'run');
|
||||
}).catch(() => {
|
||||
this.$post('/test/plan/load/case/update', {id: loadCase.id, status: "error"}, () => {
|
||||
this.initTable();
|
||||
});
|
||||
this.updateStatus(loadCase, 'error');
|
||||
this.$notify.error({
|
||||
title: loadCase.caseName,
|
||||
message: this.$t('test_track.plan.load_case.error').toString()
|
||||
});
|
||||
})
|
||||
},
|
||||
updateStatus(loadCase, status) {
|
||||
this.$post('/test/plan/load/case/update', {id: loadCase.id, status: status}, () => {
|
||||
this.$post('/test/plan/edit/status/' + loadCase.testPlanId, {},() => {
|
||||
this.initTable();
|
||||
});
|
||||
});
|
||||
},
|
||||
handleDelete(loadCase) {
|
||||
this.result = this.$get('/test/plan/load/case/delete/' + loadCase.id, () => {
|
||||
this.$success(this.$t('test_track.cancel_relevance_success'));
|
||||
|
|
Loading…
Reference in New Issue