refactor(接口测试): 优化mock后置脚本设置变量模版
--bug=1032552 --user=王孝刚 【接口测试】github#27302,接口测试mock, 后置脚本python设置变量失败 https://www.tapd.cn/55049933/s/1433894
This commit is contained in:
parent
5e866b2a22
commit
b645407fa4
|
@ -140,7 +140,7 @@ export default {
|
|||
children: [
|
||||
{
|
||||
title: i18n.t('api_test.request.processor.code_template_get_variable'),
|
||||
value: 'vars.get("variable_name");',
|
||||
value: this.getCustomVariable(),
|
||||
},
|
||||
{
|
||||
title: i18n.t('api_test.request.processor.code_template_set_variable'),
|
||||
|
@ -257,6 +257,18 @@ export default {
|
|||
|
||||
return returnScript;
|
||||
},
|
||||
//获取自定义变量
|
||||
getCustomVariable() {
|
||||
let returnScript = '';
|
||||
if (this.jsr223Processor) {
|
||||
if (this.jsr223Processor.scriptLanguage === 'python') {
|
||||
returnScript = 'vars["variable_name"]';
|
||||
} else {
|
||||
returnScript = 'vars.get("variable_name")';
|
||||
}
|
||||
}
|
||||
return returnScript;
|
||||
},
|
||||
addTemplate(template) {
|
||||
if (!this.jsr223Processor.script) {
|
||||
this.jsr223Processor.script = '';
|
||||
|
|
Loading…
Reference in New Issue