Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MeterSphere
metersphere
提交
fb224d22
M
metersphere
项目概览
MeterSphere
/
metersphere
上一次同步 大约 3 年
通知
25
Star
1
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
metersphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
fb224d22
编写于
10月 19, 2020
作者:
Q
q4speed
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(接口测试): 断言增加忽略状态
上级
ae474fad
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
163 addition
and
131 deletion
+163
-131
backend/src/main/java/io/metersphere/api/dto/scenario/assertions/AssertionRegex.java
...tersphere/api/dto/scenario/assertions/AssertionRegex.java
+1
-0
frontend/src/business/components/api/test/components/assertion/ApiAssertionRegex.vue
...nents/api/test/components/assertion/ApiAssertionRegex.vue
+70
-59
frontend/src/business/components/api/test/components/assertion/ApiAssertionText.vue
...onents/api/test/components/assertion/ApiAssertionText.vue
+77
-65
frontend/src/business/components/api/test/model/JMX.js
frontend/src/business/components/api/test/model/JMX.js
+7
-4
frontend/src/business/components/api/test/model/ScenarioModel.js
...d/src/business/components/api/test/model/ScenarioModel.js
+5
-3
frontend/src/i18n/en-US.js
frontend/src/i18n/en-US.js
+1
-0
frontend/src/i18n/zh-CN.js
frontend/src/i18n/zh-CN.js
+1
-0
frontend/src/i18n/zh-TW.js
frontend/src/i18n/zh-TW.js
+1
-0
未找到文件。
backend/src/main/java/io/metersphere/api/dto/scenario/assertions/AssertionRegex.java
浏览文件 @
fb224d22
...
...
@@ -9,6 +9,7 @@ public class AssertionRegex extends AssertionType {
private
String
subject
;
private
String
expression
;
private
String
description
;
private
Boolean
assumeSuccess
;
public
AssertionRegex
()
{
setType
(
AssertionType
.
REGEX
);
...
...
frontend/src/business/components/api/test/components/assertion/ApiAssertionRegex.vue
浏览文件 @
fb224d22
...
...
@@ -13,8 +13,14 @@
<el-input
:disabled=
"isReadOnly"
v-model=
"regex.expression"
size=
"small"
show-word-limit
:placeholder=
"$t('api_test.request.assertions.expression')"
/>
</el-col>
<el-col
class=
"assertion-checkbox"
>
<el-checkbox
v-model=
"regex.assumeSuccess"
:disabled=
"isReadOnly"
>
{{
$t
(
'
api_test.request.assertions.ignore_status
'
)
}}
</el-checkbox>
</el-col>
<el-col
class=
"assertion-btn"
>
<el-button
:disabled=
"isReadOnly"
type=
"danger"
size=
"mini"
icon=
"el-icon-delete"
circle
@
click=
"remove"
v-if=
"edit"
/>
<el-button
:disabled=
"isReadOnly"
type=
"danger"
size=
"mini"
icon=
"el-icon-delete"
circle
@
click=
"remove"
v-if=
"edit"
/>
<el-button
:disabled=
"isReadOnly"
type=
"primary"
size=
"small"
@
click=
"add"
v-else
>
Add
</el-button>
</el-col>
</el-row>
...
...
@@ -22,77 +28,82 @@
</
template
>
<
script
>
import
{
ASSERTION_REGEX_SUBJECT
,
Regex
}
from
"
../../model/ScenarioModel
"
;
import
{
ASSERTION_REGEX_SUBJECT
,
Regex
}
from
"
../../model/ScenarioModel
"
;
export
default
{
name
:
"
MsApiAssertionRegex
"
,
export
default
{
name
:
"
MsApiAssertionRegex
"
,
props
:
{
regex
:
{
type
:
Regex
,
default
:
()
=>
{
return
new
Regex
();
}
},
edit
:
{
type
:
Boolean
,
default
:
false
},
index
:
Number
,
list
:
Array
,
callback
:
Function
,
isReadOnly
:
{
type
:
Boolean
,
default
:
false
props
:
{
regex
:
{
type
:
Regex
,
default
:
()
=>
{
return
new
Regex
();
}
},
data
()
{
return
{
subjects
:
ASSERTION_REGEX_SUBJECT
,
}
edit
:
{
type
:
Boolean
,
default
:
false
},
index
:
Number
,
list
:
Array
,
callback
:
Function
,
isReadOnly
:
{
type
:
Boolean
,
default
:
false
}
},
watch
:
{
'
regex.subject
'
()
{
this
.
setRegexDescription
();
},
'
regex.expression
'
()
{
this
.
setRegexDescription
();
}
data
()
{
return
{
subjects
:
ASSERTION_REGEX_SUBJECT
,
}
},
watch
:
{
'
regex.subject
'
()
{
this
.
setRegexDescription
();
},
'
regex.expression
'
()
{
this
.
setRegexDescription
();
}
},
methods
:
{
add
:
function
()
{
this
.
list
.
push
(
this
.
getRegex
());
this
.
callback
();
},
remove
:
function
()
{
this
.
list
.
splice
(
this
.
index
,
1
);
},
getRegex
()
{
let
regex
=
new
Regex
(
this
.
regex
);
regex
.
description
=
regex
.
subject
+
"
has:
"
+
regex
.
expression
;
return
regex
;
},
setRegexDescription
()
{
this
.
regex
.
description
=
this
.
regex
.
subject
+
"
has:
"
+
this
.
regex
.
expression
;
}
methods
:
{
add
:
function
()
{
this
.
list
.
push
(
this
.
getRegex
());
this
.
callback
();
},
remove
:
function
()
{
this
.
list
.
splice
(
this
.
index
,
1
);
},
getRegex
()
{
let
regex
=
new
Regex
(
this
.
regex
);
regex
.
description
=
regex
.
subject
+
"
has:
"
+
regex
.
expression
;
return
regex
;
},
setRegexDescription
()
{
this
.
regex
.
description
=
this
.
regex
.
subject
+
"
has:
"
+
this
.
regex
.
expression
;
}
}
}
</
script
>
<
style
scoped
>
.assertion-select
{
width
:
250px
;
}
.assertion-select
{
width
:
250px
;
}
.assertion-item
{
width
:
100%
;
}
.assertion-item
{
width
:
100%
;
}
.assertion-btn
{
text-align
:
center
;
width
:
60px
;
}
.assertion-checkbox
{
text-align
:
center
;
width
:
120px
;
}
.assertion-btn
{
text-align
:
center
;
width
:
60px
;
}
</
style
>
frontend/src/business/components/api/test/components/assertion/ApiAssertionText.vue
浏览文件 @
fb224d22
...
...
@@ -23,88 +23,100 @@
<el-input
:disabled=
"isReadOnly"
v-model=
"value"
maxlength=
"200"
size=
"small"
show-word-limit
:placeholder=
"$t('api_test.request.assertions.value')"
/>
</el-col>
<el-col
class=
"assertion-checkbox"
>
<el-checkbox
v-model=
"assumeSuccess"
:disabled=
"isReadOnly"
>
{{
$t
(
'
api_test.request.assertions.ignore_status
'
)
}}
</el-checkbox>
</el-col>
<el-col
class=
"assertion-btn"
>
<el-button
:disabled=
"isReadOnly"
type=
"primary"
size=
"small"
@
click=
"add"
>
Add
</el-button>
<el-button
:disabled=
"isReadOnly"
type=
"primary"
size=
"small"
@
click=
"add"
>
Add
</el-button>
</el-col>
</el-row>
</div>
</
template
>
<
script
>
import
{
Regex
,
ASSERTION_REGEX_SUBJECT
}
from
"
../../model/ScenarioModel
"
;
import
{
Regex
,
ASSERTION_REGEX_SUBJECT
}
from
"
../../model/ScenarioModel
"
;
export
default
{
name
:
"
MsApiAssertionText
"
,
export
default
{
name
:
"
MsApiAssertionText
"
,
props
:
{
list
:
Array
,
callback
:
Function
,
isReadOnly
:
{
type
:
Boolean
,
default
:
false
}
},
props
:
{
list
:
Array
,
callback
:
Function
,
isReadOnly
:
{
type
:
Boolean
,
default
:
false
}
},
data
()
{
return
{
subjects
:
ASSERTION_REGEX_SUBJECT
,
subject
:
""
,
condition
:
""
,
value
:
""
}
},
data
()
{
return
{
subjects
:
ASSERTION_REGEX_SUBJECT
,
subject
:
""
,
condition
:
""
,
assumeSuccess
:
false
,
value
:
""
}
},
methods
:
{
add
:
function
()
{
this
.
list
.
push
(
this
.
toRegex
());
this
.
callback
();
},
toRegex
:
function
()
{
let
expression
=
""
;
let
description
=
this
.
subject
;
switch
(
this
.
condition
)
{
case
"
CONTAINS
"
:
expression
=
"
.*
"
+
this
.
value
+
"
.*
"
;
description
+=
"
contains:
"
+
this
.
value
;
break
;
case
"
NOT_CONTAINS
"
:
expression
=
"
(?s)^((?!
"
+
this
.
value
+
"
).)*$
"
;
description
+=
"
not contains:
"
+
this
.
value
;
break
;
case
"
EQUALS
"
:
expression
=
"
^
"
+
this
.
value
+
"
$
"
;
description
+=
"
equals:
"
+
this
.
value
;
break
;
case
"
START_WITH
"
:
expression
=
"
^
"
+
this
.
value
;
description
+=
"
start with:
"
+
this
.
value
;
break
;
case
"
END_WITH
"
:
expression
=
this
.
value
+
"
$
"
;
description
+=
"
end with:
"
+
this
.
value
;
break
;
}
return
new
Regex
({
subject
:
this
.
subject
,
expression
:
expression
,
description
:
description
}
);
methods
:
{
add
:
function
()
{
this
.
list
.
push
(
this
.
toRegex
());
this
.
callback
();
},
toRegex
:
function
()
{
let
expression
=
""
;
let
description
=
this
.
subject
;
switch
(
this
.
condition
)
{
case
"
CONTAINS
"
:
expression
=
"
.*
"
+
this
.
value
+
"
.*
"
;
description
+=
"
contains:
"
+
this
.
value
;
break
;
case
"
NOT_CONTAINS
"
:
expression
=
"
(?s)^((?!
"
+
this
.
value
+
"
).)*$
"
;
description
+=
"
not contains:
"
+
this
.
value
;
break
;
case
"
EQUALS
"
:
expression
=
"
^
"
+
this
.
value
+
"
$
"
;
description
+=
"
equals:
"
+
this
.
value
;
break
;
case
"
START_WITH
"
:
expression
=
"
^
"
+
this
.
value
;
description
+=
"
start with:
"
+
this
.
value
;
break
;
case
"
END_WITH
"
:
expression
=
this
.
value
+
"
$
"
;
description
+=
"
end with:
"
+
this
.
value
;
break
;
}
return
new
Regex
({
subject
:
this
.
subject
,
expression
:
expression
,
description
:
description
,
assumeSuccess
:
this
.
assumeSuccess
}
);
}
}
}
</
script
>
<
style
scoped
>
.assertion-select
{
width
:
250px
;
}
.assertion-select
{
width
:
250px
;
}
.assertion-item
{
width
:
100%
;
}
.assertion-item
{
width
:
100%
;
}
.assertion-btn
{
width
:
60px
;
}
.assertion-checkbox
{
text-align
:
center
;
width
:
120px
;
}
.assertion-btn
{
width
:
60px
;
}
</
style
>
frontend/src/business/components/api/test/model/JMX.js
浏览文件 @
fb224d22
...
...
@@ -415,7 +415,7 @@ export class ResponseAssertion extends DefaultTestElement {
this
.
assertion
=
assertion
||
{};
this
.
stringProp
(
'
Assertion.test_field
'
,
this
.
assertion
.
field
);
this
.
boolProp
(
'
Assertion.assume_success
'
,
false
);
this
.
boolProp
(
'
Assertion.assume_success
'
,
this
.
assertion
.
assumeSuccess
);
this
.
intProp
(
'
Assertion.test_type
'
,
this
.
assertion
.
type
);
this
.
stringProp
(
'
Assertion.custom_message
'
,
this
.
assertion
.
message
);
...
...
@@ -440,11 +440,12 @@ export class JSONPathAssertion extends DefaultTestElement {
}
export
class
ResponseCodeAssertion
extends
ResponseAssertion
{
constructor
(
testName
,
type
,
value
,
message
)
{
constructor
(
testName
,
type
,
value
,
assumeSuccess
,
message
)
{
let
assertion
=
{
field
:
'
Assertion.response_code
'
,
type
:
type
,
value
:
value
,
assumeSuccess
:
assumeSuccess
,
message
:
message
,
}
super
(
testName
,
assertion
)
...
...
@@ -452,11 +453,12 @@ export class ResponseCodeAssertion extends ResponseAssertion {
}
export
class
ResponseDataAssertion
extends
ResponseAssertion
{
constructor
(
testName
,
type
,
value
,
message
)
{
constructor
(
testName
,
type
,
value
,
assumeSuccess
,
message
)
{
let
assertion
=
{
field
:
'
Assertion.response_data
'
,
type
:
type
,
value
:
value
,
assumeSuccess
:
assumeSuccess
,
message
:
message
,
}
super
(
testName
,
assertion
)
...
...
@@ -464,11 +466,12 @@ export class ResponseDataAssertion extends ResponseAssertion {
}
export
class
ResponseHeadersAssertion
extends
ResponseAssertion
{
constructor
(
testName
,
type
,
value
,
message
)
{
constructor
(
testName
,
type
,
value
,
assumeSuccess
,
message
)
{
let
assertion
=
{
field
:
'
Assertion.response_headers
'
,
type
:
type
,
value
:
value
,
assumeSuccess
:
assumeSuccess
,
message
:
message
,
}
super
(
testName
,
assertion
)
...
...
frontend/src/business/components/api/test/model/ScenarioModel.js
浏览文件 @
fb224d22
...
...
@@ -785,6 +785,7 @@ export class Regex extends AssertionType {
this
.
subject
=
undefined
;
this
.
expression
=
undefined
;
this
.
description
=
undefined
;
this
.
assumeSuccess
=
false
;
this
.
set
(
options
);
}
...
...
@@ -1423,13 +1424,14 @@ class JMXGenerator {
let
name
=
regex
.
description
;
let
type
=
JMX_ASSERTION_CONDITION
.
CONTAINS
;
// 固定用Match,自己写正则
let
value
=
regex
.
expression
;
let
assumeSuccess
=
regex
.
assumeSuccess
;
switch
(
regex
.
subject
)
{
case
ASSERTION_REGEX_SUBJECT
.
RESPONSE_CODE
:
return
new
ResponseCodeAssertion
(
name
,
type
,
value
);
return
new
ResponseCodeAssertion
(
name
,
type
,
value
,
assumeSuccess
);
case
ASSERTION_REGEX_SUBJECT
.
RESPONSE_DATA
:
return
new
ResponseDataAssertion
(
name
,
type
,
value
);
return
new
ResponseDataAssertion
(
name
,
type
,
value
,
assumeSuccess
);
case
ASSERTION_REGEX_SUBJECT
.
RESPONSE_HEADERS
:
return
new
ResponseHeadersAssertion
(
name
,
type
,
value
);
return
new
ResponseHeadersAssertion
(
name
,
type
,
value
,
assumeSuccess
);
}
}
...
...
frontend/src/i18n/en-US.js
浏览文件 @
fb224d22
...
...
@@ -526,6 +526,7 @@ export default {
expect
:
"
Expect Value
"
,
expression
:
"
Expression
"
,
response_in_time
:
"
Response in time
"
,
ignore_status
:
"
Ignore Status
"
},
extract
:
{
label
:
"
Extract from response
"
,
...
...
frontend/src/i18n/zh-CN.js
浏览文件 @
fb224d22
...
...
@@ -527,6 +527,7 @@ export default {
expect
:
"
期望值
"
,
expression
:
"
Perl型正则表达式
"
,
response_in_time
:
"
响应时间在...毫秒以内
"
,
ignore_status
:
"
忽略状态
"
},
extract
:
{
label
:
"
提取
"
,
...
...
frontend/src/i18n/zh-TW.js
浏览文件 @
fb224d22
...
...
@@ -527,6 +527,7 @@ export default {
expect
:
"
期望值
"
,
expression
:
"
Perl型正則表達式
"
,
response_in_time
:
"
響應時間在...毫秒以內
"
,
ignore_status
:
"
忽略狀態
"
},
extract
:
{
label
:
"
提取
"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录