fix(接口自动化): 修复调试结果匹配问题,log日志不全问题,导出报错问题

This commit is contained in:
fit2-zhao 2021-07-23 12:36:10 +08:00 committed by fit2-zhao
parent 45988d225e
commit 5673555d2d
4 changed files with 37 additions and 14 deletions

View File

@ -68,6 +68,9 @@ public class MsAssertions extends MsTestElement {
ResponseAssertion assertion = new ResponseAssertion(); ResponseAssertion assertion = new ResponseAssertion();
assertion.setEnabled(this.isEnable()); assertion.setEnabled(this.isEnable());
assertion.setName(assertionRegex.getDescription()); assertion.setName(assertionRegex.getDescription());
if(StringUtils.isEmpty(assertionRegex.getDescription())){
assertion.setName("AssertionRegex");
}
assertion.setName(StringUtils.isNotEmpty(assertionRegex.getDescription()) ? assertionRegex.getDescription() : this.getName()); assertion.setName(StringUtils.isNotEmpty(assertionRegex.getDescription()) ? assertionRegex.getDescription() : this.getName());
assertion.setProperty(TestElement.TEST_CLASS, ResponseAssertion.class.getName()); assertion.setProperty(TestElement.TEST_CLASS, ResponseAssertion.class.getName());
assertion.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("AssertionGui")); assertion.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("AssertionGui"));
@ -94,6 +97,9 @@ public class MsAssertions extends MsTestElement {
JSONPathAssertion assertion = new JSONPathAssertion(); JSONPathAssertion assertion = new JSONPathAssertion();
assertion.setEnabled(this.isEnable()); assertion.setEnabled(this.isEnable());
assertion.setName(StringUtils.isNotEmpty(assertionJsonPath.getDescription()) ? assertionJsonPath.getDescription() : this.getName()); assertion.setName(StringUtils.isNotEmpty(assertionJsonPath.getDescription()) ? assertionJsonPath.getDescription() : this.getName());
if(StringUtils.isEmpty(assertion.getName())){
assertion.setName("JSONPathAssertion");
}
/* assertion.setName(StringUtils.isNotEmpty(this.getName()) ? this.getName() : "JSONPathAssertion");*/ /* assertion.setName(StringUtils.isNotEmpty(this.getName()) ? this.getName() : "JSONPathAssertion");*/
assertion.setProperty(TestElement.TEST_CLASS, JSONPathAssertion.class.getName()); assertion.setProperty(TestElement.TEST_CLASS, JSONPathAssertion.class.getName());
assertion.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("JSONPathAssertionGui")); assertion.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("JSONPathAssertionGui"));
@ -115,6 +121,9 @@ public class MsAssertions extends MsTestElement {
XPath2Assertion assertion = new XPath2Assertion(); XPath2Assertion assertion = new XPath2Assertion();
assertion.setEnabled(this.isEnable()); assertion.setEnabled(this.isEnable());
assertion.setName(StringUtils.isNotEmpty(assertionXPath2.getExpression()) ? assertionXPath2.getExpression() : this.getName()); assertion.setName(StringUtils.isNotEmpty(assertionXPath2.getExpression()) ? assertionXPath2.getExpression() : this.getName());
if(StringUtils.isEmpty(assertion.getName())){
assertion.setName("XPath2Assertion");
}
/*assertion.setName(StringUtils.isNotEmpty(this.getName()) ? this.getName() : "XPath2Assertion");*/ /*assertion.setName(StringUtils.isNotEmpty(this.getName()) ? this.getName() : "XPath2Assertion");*/
assertion.setProperty(TestElement.TEST_CLASS, XPath2Assertion.class.getName()); assertion.setProperty(TestElement.TEST_CLASS, XPath2Assertion.class.getName());
assertion.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("XPath2AssertionGui")); assertion.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("XPath2AssertionGui"));
@ -138,6 +147,9 @@ public class MsAssertions extends MsTestElement {
JSR223Assertion assertion = new JSR223Assertion(); JSR223Assertion assertion = new JSR223Assertion();
assertion.setEnabled(this.isEnable()); assertion.setEnabled(this.isEnable());
assertion.setName(StringUtils.isNotEmpty(assertionJSR223.getDesc()) ? assertionJSR223.getDesc() : this.getName()); assertion.setName(StringUtils.isNotEmpty(assertionJSR223.getDesc()) ? assertionJSR223.getDesc() : this.getName());
if(StringUtils.isEmpty(assertion.getName())){
assertion.setName("JSR223Assertion");
}
/*assertion.setName(StringUtils.isNotEmpty(this.getName()) ? this.getName() : "JSR223Assertion");*/ /*assertion.setName(StringUtils.isNotEmpty(this.getName()) ? this.getName() : "JSR223Assertion");*/
assertion.setProperty(TestElement.TEST_CLASS, JSR223Assertion.class.getName()); assertion.setProperty(TestElement.TEST_CLASS, JSR223Assertion.class.getName());
assertion.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI")); assertion.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI"));

View File

@ -72,6 +72,9 @@ public class MsExtract extends MsTestElement {
RegexExtractor extractor = new RegexExtractor(); RegexExtractor extractor = new RegexExtractor();
extractor.setEnabled(this.isEnable()); extractor.setEnabled(this.isEnable());
extractor.setName(StringUtils.isNotEmpty(extractRegex.getVariable()) ? extractRegex.getVariable() : this.getName()); extractor.setName(StringUtils.isNotEmpty(extractRegex.getVariable()) ? extractRegex.getVariable() : this.getName());
if(StringUtils.isEmpty(extractor.getName())){
extractor.setName("RegexExtractor");
}
/*extractor.setName(StringUtils.isNotEmpty(this.getName()) ? this.getName() : " RegexExtractor");*/ /*extractor.setName(StringUtils.isNotEmpty(this.getName()) ? this.getName() : " RegexExtractor");*/
extractor.setProperty(TestElement.TEST_CLASS, RegexExtractor.class.getName()); extractor.setProperty(TestElement.TEST_CLASS, RegexExtractor.class.getName());
extractor.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("RegexExtractorGui")); extractor.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("RegexExtractorGui"));
@ -91,6 +94,9 @@ public class MsExtract extends MsTestElement {
XPath2Extractor extractor = new XPath2Extractor(); XPath2Extractor extractor = new XPath2Extractor();
extractor.setEnabled(this.isEnable()); extractor.setEnabled(this.isEnable());
extractor.setName(StringUtils.isNotEmpty(extractXPath.getVariable()) ? extractXPath.getVariable() : this.getName()); extractor.setName(StringUtils.isNotEmpty(extractXPath.getVariable()) ? extractXPath.getVariable() : this.getName());
if(StringUtils.isEmpty(extractor.getName())){
extractor.setName("XPath2Extractor");
}
/*extractor.setName(StringUtils.isNotEmpty(this.getName()) ? this.getName() : " XPath2Extractor");*/ /*extractor.setName(StringUtils.isNotEmpty(this.getName()) ? this.getName() : " XPath2Extractor");*/
extractor.setProperty(TestElement.TEST_CLASS, XPath2Extractor.class.getName()); extractor.setProperty(TestElement.TEST_CLASS, XPath2Extractor.class.getName());
extractor.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("XPath2ExtractorGui")); extractor.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("XPath2ExtractorGui"));
@ -107,6 +113,9 @@ public class MsExtract extends MsTestElement {
JSONPostProcessor extractor = new JSONPostProcessor(); JSONPostProcessor extractor = new JSONPostProcessor();
extractor.setEnabled(this.isEnable()); extractor.setEnabled(this.isEnable());
extractor.setName(StringUtils.isNotEmpty(extractJSONPath.getVariable()) ? extractJSONPath.getVariable() : this.getName()); extractor.setName(StringUtils.isNotEmpty(extractJSONPath.getVariable()) ? extractJSONPath.getVariable() : this.getName());
if(StringUtils.isEmpty(extractor.getName())){
extractor.setName("JSONPostProcessor");
}
/*extractor.setName(StringUtils.isNotEmpty(this.getName()) ? this.getName() : " JSONExtractor");*/ /*extractor.setName(StringUtils.isNotEmpty(this.getName()) ? this.getName() : " JSONExtractor");*/
extractor.setProperty(TestElement.TEST_CLASS, JSONPostProcessor.class.getName()); extractor.setProperty(TestElement.TEST_CLASS, JSONPostProcessor.class.getName());
extractor.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("JSONPostProcessorGui")); extractor.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("JSONPostProcessorGui"));

View File

@ -17,7 +17,6 @@ public class JmeterLoggerAppender extends UnsynchronizedAppenderBase<ILoggingEve
if (logger == null) { if (logger == null) {
logger = new LinkedHashMap<>(); logger = new LinkedHashMap<>();
} }
if (event.getLevel().levelStr.equals(LogUtil.INFO)) {
StringBuffer message = new StringBuffer(); StringBuffer message = new StringBuffer();
message.append(DateUtils.getTimeStr(event.getTimeStamp())).append(" ") message.append(DateUtils.getTimeStr(event.getTimeStamp())).append(" ")
.append(event.getLevel()).append(" ") .append(event.getLevel()).append(" ")
@ -28,7 +27,6 @@ public class JmeterLoggerAppender extends UnsynchronizedAppenderBase<ILoggingEve
} else { } else {
logger.put(event.getTimeStamp(), message); logger.put(event.getTimeStamp(), message);
} }
}
} catch (Exception e) { } catch (Exception e) {
LogUtil.error(e); LogUtil.error(e);
} }

View File

@ -886,11 +886,11 @@ export default {
} }
}); });
}, },
copySetRes(hashTree) { resetResourceId(hashTree) {
hashTree.forEach(item => { hashTree.forEach(item => {
item.resourceId = getUUID(); item.resourceId = getUUID();
if (item.hashTree && item.hashTree.length > 0) { if (item.hashTree && item.hashTree.length > 0) {
this.copySetRes(item.hashTree); this.resetResourceId(item.hashTree);
} }
}) })
}, },
@ -901,7 +901,7 @@ export default {
let obj = JSON.parse(JSON.stringify(row)); let obj = JSON.parse(JSON.stringify(row));
obj.resourceId = getUUID(); obj.resourceId = getUUID();
if (obj.hashTree && obj.hashTree.length > 0) { if (obj.hashTree && obj.hashTree.length > 0) {
this.copySetRes(obj.hashTree); this.resetResourceId(obj.hashTree);
} }
if (obj.name) { if (obj.name) {
obj.name = obj.name + '_copy'; obj.name = obj.name + '_copy';
@ -1133,6 +1133,10 @@ export default {
this.sort(); this.sort();
}) })
} }
// resourceId
if (this.scenarioDefinition) {
this.resetResourceId(this.scenarioDefinition);
}
}, },
setParameter() { setParameter() {
this.currentScenario.stepTotal = this.scenarioDefinition.length; this.currentScenario.stepTotal = this.scenarioDefinition.length;