fix(接口自动化): 测试报告循环控制器层级显示问题修复

This commit is contained in:
fit2-zhao 2021-06-17 14:56:15 +08:00 committed by fit2-zhao
parent 0bec8af6c4
commit c2157e48d9
1 changed files with 20 additions and 18 deletions

View File

@ -77,7 +77,7 @@ import java.util.stream.Collectors;
}) })
@JSONType(seeAlso = {MsHTTPSamplerProxy.class, MsHeaderManager.class, MsJSR223Processor.class, MsJSR223PostProcessor.class, @JSONType(seeAlso = {MsHTTPSamplerProxy.class, MsHeaderManager.class, MsJSR223Processor.class, MsJSR223PostProcessor.class,
MsJSR223PreProcessor.class, MsTestPlan.class, MsThreadGroup.class, MsAuthManager.class, MsAssertions.class, MsJSR223PreProcessor.class, MsTestPlan.class, MsThreadGroup.class, MsAuthManager.class, MsAssertions.class,
MsExtract.class, MsTCPSampler.class, MsDubboSampler.class, MsJDBCSampler.class, MsConstantTimer.class, MsIfController.class,MsTransactionController.class, MsScenario.class, MsLoopController.class, MsJmeterElement.class}, typeKey = "type") MsExtract.class, MsTCPSampler.class, MsDubboSampler.class, MsJDBCSampler.class, MsConstantTimer.class, MsIfController.class, MsTransactionController.class, MsScenario.class, MsLoopController.class, MsJmeterElement.class}, typeKey = "type")
@Data @Data
public abstract class MsTestElement { public abstract class MsTestElement {
private String type; private String type;
@ -257,7 +257,20 @@ public abstract class MsTestElement {
if (element.getParent() == null) { if (element.getParent() == null) {
return path; return path;
} }
path = StringUtils.isEmpty(element.getName()) ? element.getType() : element.getName() + DelimiterConstants.STEP_DELIMITER.toString() + path; if (MsTestElementConstants.LoopController.name().equals(element.getType())) {
MsLoopController loopController = (MsLoopController) element;
if (StringUtils.equals(loopController.getLoopType(), LoopConstants.WHILE.name()) && loopController.getWhileController() != null) {
path = "While 循环" + DelimiterConstants.STEP_DELIMITER.toString() + "While 循环-" + "${MS_LOOP_CONTROLLER_CONFIG}";
}
if (StringUtils.equals(loopController.getLoopType(), LoopConstants.FOREACH.name()) && loopController.getForEachController() != null) {
path = "ForEach 循环" + DelimiterConstants.STEP_DELIMITER.toString() + " ForEach 循环-" + "${MS_LOOP_CONTROLLER_CONFIG}";
}
if (StringUtils.equals(loopController.getLoopType(), LoopConstants.LOOP_COUNT.name()) && loopController.getCountController() != null) {
path = "次数循环" + DelimiterConstants.STEP_DELIMITER.toString() + "次数循环-" + "${MS_LOOP_CONTROLLER_CONFIG}";
}
} else {
path = StringUtils.isEmpty(element.getName()) ? element.getType() : element.getName() + DelimiterConstants.STEP_DELIMITER.toString() + path;
}
return getFullPath(element.getParent(), path); return getFullPath(element.getParent(), path);
} }
@ -273,24 +286,13 @@ public abstract class MsTestElement {
protected String getParentName(MsTestElement parent) { protected String getParentName(MsTestElement parent) {
if (parent != null) { if (parent != null) {
if (MsTestElementConstants.LoopController.name().equals(parent.getType())) { if (MsTestElementConstants.TransactionController.name().equals(parent.getType())) {
MsLoopController loopController = (MsLoopController) parent; MsTransactionController transactionController = (MsTransactionController) parent;
if (StringUtils.equals(loopController.getLoopType(), LoopConstants.WHILE.name()) && loopController.getWhileController() != null) { if (StringUtils.isNotEmpty(transactionController.getName())) {
return "While 循环-" + "${MS_LOOP_CONTROLLER_CONFIG}";
}
if (StringUtils.equals(loopController.getLoopType(), LoopConstants.FOREACH.name()) && loopController.getForEachController() != null) {
return "ForEach 循环-" + "${MS_LOOP_CONTROLLER_CONFIG}";
}
if (StringUtils.equals(loopController.getLoopType(), LoopConstants.LOOP_COUNT.name()) && loopController.getCountController() != null) {
return "次数循环-" + "${MS_LOOP_CONTROLLER_CONFIG}";
}
}else if(MsTestElementConstants.TransactionController.name().equals(parent.getType())){
MsTransactionController transactionController = (MsTransactionController)parent;
if(StringUtils.isNotEmpty(transactionController.getName())){
return transactionController.getName(); return transactionController.getName();
}else if(StringUtils.isNotEmpty(transactionController.getLabelName())){ } else if (StringUtils.isNotEmpty(transactionController.getLabelName())) {
return transactionController.getLabelName(); return transactionController.getLabelName();
}else { } else {
return "TransactionController"; return "TransactionController";
} }
} }