fix(接口测试): 场景中禁用的步骤批量执行时也生成了报告步骤
This commit is contained in:
parent
5fb59a66f7
commit
ecac585d31
|
@ -138,7 +138,7 @@ public class ApiScenarioBatchRunService {
|
||||||
|
|
||||||
String reportId = null;
|
String reportId = null;
|
||||||
try {
|
try {
|
||||||
ApiScenarioDetail apiScenarioDetail = apiScenarioService.get(id);
|
ApiScenarioDetail apiScenarioDetail = apiScenarioService.getForRun(id);
|
||||||
if (apiScenarioDetail == null) {
|
if (apiScenarioDetail == null) {
|
||||||
if (runModeConfig.isIntegratedReport()) {
|
if (runModeConfig.isIntegratedReport()) {
|
||||||
// 用例不存在,则在执行集合中删除
|
// 用例不存在,则在执行集合中删除
|
||||||
|
@ -281,7 +281,7 @@ public class ApiScenarioBatchRunService {
|
||||||
* @param queueDetail
|
* @param queueDetail
|
||||||
*/
|
*/
|
||||||
public void executeNextTask(ExecutionQueue queue, ExecutionQueueDetail queueDetail) {
|
public void executeNextTask(ExecutionQueue queue, ExecutionQueueDetail queueDetail) {
|
||||||
ApiScenarioDetail apiScenarioDetail = apiScenarioService.get(queueDetail.getResourceId());
|
ApiScenarioDetail apiScenarioDetail = apiScenarioService.getForRun(queueDetail.getResourceId());
|
||||||
if (apiScenarioDetail == null) {
|
if (apiScenarioDetail == null) {
|
||||||
LogUtils.info("当前执行任务的用例已删除 {}", queueDetail.getResourceId());
|
LogUtils.info("当前执行任务的用例已删除 {}", queueDetail.getResourceId());
|
||||||
return;
|
return;
|
||||||
|
@ -405,7 +405,7 @@ public class ApiScenarioBatchRunService {
|
||||||
}
|
}
|
||||||
Long requestCount = 0L;
|
Long requestCount = 0L;
|
||||||
while (queueDetail != null) {
|
while (queueDetail != null) {
|
||||||
ApiScenarioDetail apiScenarioDetail = apiScenarioService.get(queueDetail.getResourceId());
|
ApiScenarioDetail apiScenarioDetail = apiScenarioService.getForRun(queueDetail.getResourceId());
|
||||||
if (apiScenarioDetail == null) {
|
if (apiScenarioDetail == null) {
|
||||||
LogUtils.info("当前场景已删除 {}", queueDetail.getResourceId());
|
LogUtils.info("当前场景已删除 {}", queueDetail.getResourceId());
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -1275,7 +1275,7 @@ public class ApiScenarioService extends MoveNodeService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public TaskRequestDTO run(String id, String reportId, String userId) {
|
public TaskRequestDTO run(String id, String reportId, String userId) {
|
||||||
ApiScenarioDetail apiScenarioDetail = get(id);
|
ApiScenarioDetail apiScenarioDetail = getForRun(id);
|
||||||
|
|
||||||
// 解析生成待执行的场景树
|
// 解析生成待执行的场景树
|
||||||
MsScenario msScenario = new MsScenario();
|
MsScenario msScenario = new MsScenario();
|
||||||
|
@ -1942,9 +1942,34 @@ public class ApiScenarioService extends MoveNodeService {
|
||||||
return apiScenarios.getFirst();
|
return apiScenarios.getFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ApiScenarioDetail getForRun(String scenarioId) {
|
||||||
|
ApiScenarioDetail apiScenarioDetail = get(scenarioId);
|
||||||
|
filerDisableSteps(apiScenarioDetail.getSteps());
|
||||||
|
return apiScenarioDetail;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 过滤掉禁用的步骤
|
||||||
|
*/
|
||||||
|
public List<? extends ApiScenarioStepCommonDTO> filerDisableSteps(List<? extends ApiScenarioStepCommonDTO> steps) {
|
||||||
|
if (CollectionUtils.isEmpty(steps)) {
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
return steps.stream()
|
||||||
|
.filter(step -> {
|
||||||
|
boolean isEnable = BooleanUtils.isTrue(step.getEnable());
|
||||||
|
if (isEnable) {
|
||||||
|
step.setChildren(filerDisableSteps(step.getChildren()));
|
||||||
|
}
|
||||||
|
return isEnable;
|
||||||
|
})
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
|
||||||
public ApiScenarioDetail get(String scenarioId) {
|
public ApiScenarioDetail get(String scenarioId) {
|
||||||
ApiScenario apiScenario = checkResourceIsNoDeleted(scenarioId);
|
ApiScenario apiScenario = checkResourceIsNoDeleted(scenarioId);
|
||||||
ApiScenarioDetail apiScenarioDetail = BeanUtils.copyBean(new ApiScenarioDetail(), apiScenario);
|
ApiScenarioDetail apiScenarioDetail = BeanUtils.copyBean(new ApiScenarioDetail(), apiScenario);
|
||||||
|
apiScenarioDetail.setSteps(List.of());
|
||||||
ApiScenarioBlob apiScenarioBlob = apiScenarioBlobMapper.selectByPrimaryKey(scenarioId);
|
ApiScenarioBlob apiScenarioBlob = apiScenarioBlobMapper.selectByPrimaryKey(scenarioId);
|
||||||
if (apiScenarioBlob != null) {
|
if (apiScenarioBlob != null) {
|
||||||
apiScenarioDetail.setScenarioConfig(JSON.parseObject(new String(apiScenarioBlob.getConfig()), ScenarioConfig.class));
|
apiScenarioDetail.setScenarioConfig(JSON.parseObject(new String(apiScenarioBlob.getConfig()), ScenarioConfig.class));
|
||||||
|
|
Loading…
Reference in New Issue