feat_测试报告可以查看断言脚本内容
This commit is contained in:
parent
5a7050f847
commit
dbcfc49d3c
|
@ -138,11 +138,7 @@ public class MsAssertions extends MsTestElement {
|
|||
assertion.setExpectNull(false);
|
||||
assertion.setInvert(false);
|
||||
assertion.setProperty("ASS_OPTION", assertionJsonPath.getOption());
|
||||
if (StringUtils.isEmpty(assertionJsonPath.getOption()) || "REGEX".equals(assertionJsonPath.getOption())) {
|
||||
assertion.setIsRegex(true);
|
||||
} else {
|
||||
assertion.setIsRegex(false);
|
||||
}
|
||||
assertion.setIsRegex(StringUtils.isEmpty(assertionJsonPath.getOption()) || "REGEX".equals(assertionJsonPath.getOption()));
|
||||
return assertion;
|
||||
}
|
||||
|
||||
|
@ -178,9 +174,9 @@ public class MsAssertions extends MsTestElement {
|
|||
JSR223Assertion assertion = new JSR223Assertion();
|
||||
assertion.setEnabled(this.isEnable());
|
||||
if (StringUtils.isNotEmpty(assertionJSR223.getDesc())) {
|
||||
assertion.setName(this.getName() + "==" + assertionJSR223.getDesc());
|
||||
assertion.setName("JSR223" + "==" + this.getName() + "==" + assertionJSR223.getDesc() + "==" + assertionJSR223.getScript());
|
||||
} else {
|
||||
assertion.setName(this.getName() + "==" + "JSR223Assertion");
|
||||
assertion.setName("JSR223" + "==" + this.getName() + "==" + "JSR223Assertion" + "==" + assertionJSR223.getScript());
|
||||
}
|
||||
assertion.setProperty(TestElement.TEST_CLASS, JSR223Assertion.class.getName());
|
||||
assertion.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI"));
|
||||
|
|
|
@ -9,6 +9,8 @@ public class ResponseAssertionResult {
|
|||
|
||||
private String content;
|
||||
|
||||
private String script;
|
||||
|
||||
private String message;
|
||||
|
||||
private boolean pass;
|
||||
|
|
|
@ -22,8 +22,8 @@ import java.util.stream.Collectors;
|
|||
@Transactional(rollbackFor = Exception.class)
|
||||
public class MsResultService {
|
||||
// 零时存放实时结果
|
||||
private Cache cache = Cache.newHardMemoryCache(0, 3600 * 2);
|
||||
private ConcurrentHashMap<String, List<SampleResult>> processCache = new ConcurrentHashMap<>();
|
||||
private final Cache cache = Cache.newHardMemoryCache(0, 3600 * 2);
|
||||
private final ConcurrentHashMap<String, List<SampleResult>> processCache = new ConcurrentHashMap<>();
|
||||
|
||||
public ConcurrentHashMap<String, List<SampleResult>> getProcessCache() {
|
||||
return processCache;
|
||||
|
@ -252,13 +252,21 @@ public class MsResultService {
|
|||
ResponseAssertionResult responseAssertionResult = new ResponseAssertionResult();
|
||||
responseAssertionResult.setName(assertionResult.getName());
|
||||
if (StringUtils.isNotEmpty(assertionResult.getName()) && assertionResult.getName().indexOf("==") != -1) {
|
||||
String array[] = assertionResult.getName().split("==");
|
||||
responseAssertionResult.setName(array[0]);
|
||||
StringBuffer content = new StringBuffer();
|
||||
for (int i = 1; i < array.length; i++) {
|
||||
content.append(array[i]);
|
||||
String[] array = assertionResult.getName().split("==");
|
||||
if ("JSR223".equals(array[0])) {
|
||||
responseAssertionResult.setName(array[1]);
|
||||
responseAssertionResult.setContent(array[2]);
|
||||
if (array.length > 3) {
|
||||
responseAssertionResult.setScript(array[3]);
|
||||
}
|
||||
} else {
|
||||
responseAssertionResult.setName(array[0]);
|
||||
StringBuffer content = new StringBuffer();
|
||||
for (int i = 1; i < array.length; i++) {
|
||||
content.append(array[i]);
|
||||
}
|
||||
responseAssertionResult.setContent(content.toString());
|
||||
}
|
||||
responseAssertionResult.setContent(content.toString());
|
||||
}
|
||||
responseAssertionResult.setPass(!assertionResult.isFailure() && !assertionResult.isError());
|
||||
if (!responseAssertionResult.isPass()) {
|
||||
|
|
|
@ -61,12 +61,6 @@
|
|||
</el-tag>
|
||||
</api-report-reqest-header-item>
|
||||
</div>
|
||||
|
||||
<div class="request-bottom">
|
||||
<div v-if="request.responseResult.assertions.length>0">
|
||||
<ms-assertion-results :assertions="request.responseResult.assertions"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
</div>
|
||||
|
|
|
@ -17,25 +17,79 @@
|
|||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="script">
|
||||
<template v-slot:default="{row}">
|
||||
<div class="assertion-item btn circle" v-if="row.script">
|
||||
<i class="el-icon-view el-button el-button--primary el-button--mini is-circle" circle
|
||||
@click="showPage(row.script)"/>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-dialog :title="$t('api_test.request.assertions.script')" :visible.sync="visible" width="900px" append-to-body>
|
||||
<el-row type="flex" justify="space-between" align="middle" class="quick-script-block">
|
||||
<el-col :span="codeSpan" class="script-content">
|
||||
<ms-code-edit v-if="isCodeEditAlive"
|
||||
:read-only="disabled"
|
||||
:data.sync="scriptContent" theme="eclipse" :modes="['java','python']"
|
||||
ref="codeEdit"/>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-dialog>
|
||||
</el-table>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import MsCodeEdit from "@/business/components/common/components/MsCodeEdit";
|
||||
|
||||
export default {
|
||||
name: "MsAssertionResults",
|
||||
|
||||
components: {MsCodeEdit},
|
||||
props: {
|
||||
assertions: Array
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
visible: false,
|
||||
disabled: false,
|
||||
codeSpan: 20,
|
||||
isCodeEditAlive: true,
|
||||
scriptContent: '',
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getRowStyle() {
|
||||
return {backgroundColor: "#F5F5F5"};
|
||||
}
|
||||
}
|
||||
},
|
||||
showPage(script) {
|
||||
this.disabled = true;
|
||||
this.visible = true;
|
||||
this.scriptContent = script;
|
||||
this.reload();
|
||||
},
|
||||
reload() {
|
||||
this.isCodeEditAlive = false;
|
||||
this.$nextTick(() => (this.isCodeEditAlive = true));
|
||||
},
|
||||
},
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<style scoped>
|
||||
|
||||
.assertion-item.btn.circle {
|
||||
text-align: right;
|
||||
min-width: 80px;
|
||||
}
|
||||
|
||||
.script-content {
|
||||
height: calc(100vh - 570px);
|
||||
min-height: 440px;
|
||||
}
|
||||
|
||||
.quick-script-block {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
</style>
|
||||
|
|
Loading…
Reference in New Issue