fix(接口测试): 修复脚本断言导出JMX脚本未使用自定义名称问题
--bug=1045591 --user=赵勇 [接口测试] github#32788导出jmeter脚本,脚本相关的控制名称会变成脚本内容,而不是设置好的脚本名称。 https://www.tapd.cn/55049933/s/1584418 Signed-off-by: fit2-zhao <yong.zhao@fit2cloud.com>
This commit is contained in:
parent
081f7ce2a4
commit
60277c83f0
|
@ -48,10 +48,10 @@ public class MsAssertions extends MsTestElement {
|
|||
if (StringUtils.isEmpty(this.getName())) {
|
||||
this.setName("Assertion");
|
||||
}
|
||||
addAssertions(tree);
|
||||
addAssertions(tree, config);
|
||||
}
|
||||
|
||||
private void addAssertions(HashTree hashTree) {
|
||||
private void addAssertions(HashTree hashTree, ParameterConfig config) {
|
||||
// 增加JSON文档结构校验
|
||||
if (this.getDocument() != null && this.getDocument().getType().equals("JSON") && this.getDocument().isEnable()) {
|
||||
if (StringUtils.isNotEmpty(this.getDocument().getData().getJsonFollowAPI()) && !this.getDocument().getData().getJsonFollowAPI().equals("false")) {
|
||||
|
@ -101,7 +101,7 @@ public class MsAssertions extends MsTestElement {
|
|||
|
||||
if (CollectionUtils.isNotEmpty(this.getJsr223())) {
|
||||
this.getJsr223().stream().filter(MsAssertionJSR223::isValid).forEach(assertion ->
|
||||
hashTree.add(jsr223Assertion(assertion))
|
||||
hashTree.add(jsr223Assertion(assertion, config))
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -215,7 +215,7 @@ public class MsAssertions extends MsTestElement {
|
|||
return assertion;
|
||||
}
|
||||
|
||||
private TestElement jsr223Assertion(MsAssertionJSR223 assertionJSR223) {
|
||||
private TestElement jsr223Assertion(MsAssertionJSR223 assertionJSR223, ParameterConfig config) {
|
||||
TestElement assertion = new JSR223Assertion();
|
||||
assertion.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI"));
|
||||
assertion.setProperty(TestElement.TEST_CLASS, JSR223Assertion.class.getName());
|
||||
|
@ -236,11 +236,15 @@ public class MsAssertions extends MsTestElement {
|
|||
assertion.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("BeanShellAssertionGui"));
|
||||
assertion.setProperty(BeanShellAssertion.SCRIPT, assertionJSR223.getScript());
|
||||
}
|
||||
if (StringUtils.isNotEmpty(assertionJSR223.getDesc())) {
|
||||
if (StringUtils.isNotBlank(assertionJSR223.getDesc())) {
|
||||
assertion.setName("JSR223" + delimiter + this.getName() + delimiter + assertionJSR223.getDesc() + delimiterScript + assertionJSR223.getScript());
|
||||
} else {
|
||||
assertion.setName("JSR223" + delimiter + this.getName() + delimiter + "JSR223Assertion" + delimiterScript + assertionJSR223.getScript());
|
||||
}
|
||||
// 导出操作,使用自定义名称
|
||||
if (config != null && config.isOperating()) {
|
||||
assertion.setName(StringUtils.isNotBlank(assertionJSR223.getDesc()) ? assertionJSR223.getDesc() : this.getName());
|
||||
}
|
||||
assertion.setEnabled(this.isEnable());
|
||||
assertion.setProperty("cacheKey", "false");
|
||||
assertion.setProperty("scriptLanguage", scriptLanguage);
|
||||
|
|
Loading…
Reference in New Issue