fix starts_with and ends_wih spelling

Change-Id: I1e475e8187f6e793cd9f9029af93a7d80603b26d
This commit is contained in:
buyuxiang
2022-02-14 14:41:15 +08:00
parent 5c03e0d325
commit 5bce59c583
13 changed files with 278 additions and 22 deletions

View File

@@ -42,9 +42,9 @@ Currently, HttpRunner+ has the following built-in assertion functions.
| `contains` | contains | [1, 2] contains 1 | 'abc' contains 'a', [1,2,3] len_lt 4 |
| `contained_by` | contained by | A in B | 'a' contained_by 'abc', 1 contained_by [1,2] |
| `type_match` | A and B are in the same type | type(A) == type(B) | 123 type_match 1 |
| `regex_match` | regex matches | re.match(B, A) | 'abcdef' regex 'a\w+d' |
| `starts_with` | starts with | A.startswith(B) is True | 'abc' startswith 'ab' |
| `ends_with` | ends with | A.endswith(B) is True | 'abc' endswith 'bc' |
| `regex_match` | regex matches | re.match(B, A) | 'abcdef' regex_match 'a\w+d' |
| `starts_with` | starts with | A.starts_with(B) is True | 'abc' starts_with 'ab' |
| `ends_with` | ends with | A.ends_with(B) is True | 'abc' ends_with 'bc' |
## Builtin functions

View File

@@ -2,7 +2,7 @@
## v0.6.1 (2022-02-11)
- fix: assertion function and json number parse rule
- fix: assertion function errors and json number parse rule
## v0.6.0 (2022-02-08)

View File

@@ -33,4 +33,4 @@ Copyright 2021 debugtalk
* [hrp run](hrp_run.md) - run API test
* [hrp startproject](hrp_startproject.md) - create a scaffold project
###### Auto generated by spf13/cobra on 8-Feb-2022
###### Auto generated by spf13/cobra on 14-Feb-2022

View File

@@ -39,4 +39,4 @@ hrp boom [flags]
* [hrp](hrp.md) - One-stop solution for HTTP(S) testing.
###### Auto generated by spf13/cobra on 8-Feb-2022
###### Auto generated by spf13/cobra on 14-Feb-2022

View File

@@ -23,4 +23,4 @@ hrp har2case $har_path... [flags]
* [hrp](hrp.md) - One-stop solution for HTTP(S) testing.
###### Auto generated by spf13/cobra on 8-Feb-2022
###### Auto generated by spf13/cobra on 14-Feb-2022

View File

@@ -33,4 +33,4 @@ hrp run $path... [flags]
* [hrp](hrp.md) - One-stop solution for HTTP(S) testing.
###### Auto generated by spf13/cobra on 8-Feb-2022
###### Auto generated by spf13/cobra on 14-Feb-2022

View File

@@ -16,4 +16,4 @@ hrp startproject $project_name [flags]
* [hrp](hrp.md) - One-stop solution for HTTP(S) testing.
###### Auto generated by spf13/cobra on 8-Feb-2022
###### Auto generated by spf13/cobra on 14-Feb-2022

View File

@@ -48,7 +48,7 @@
},
{
"check": "headers.\"Content-Type\"",
"assert": "startswith",
"assert": "starts_with",
"expect": "application/json"
},
{

View File

@@ -33,7 +33,7 @@ teststeps:
expect: 200
msg: check response status code
- check: headers."Content-Type"
assert: startswith
assert: starts_with
expect: application/json
- check: body.args.foo1
assert: length_equals

View File

@@ -10,21 +10,70 @@
"method": "GET",
"url": "/get",
"params": {
"a": 1
"a": 1,
"foo": "I'm a happy guy"
}
},
"validate": [
{
"check": "body.args.a",
"assert": "eq",
"expect": "1",
"msg": "check argument a"
},
{
"check": "status_code",
"assert": "greater_than",
"assert": "lt",
"expect": 201,
"msg": "check status code"
},
{
"check": "status_code",
"assert": "gt",
"expect": 199,
"msg": "check status code"
},
{
"check": "body.args.a",
"assert": "equal",
"expect": "1",
"msg": "check argument a"
"check": "status_code",
"assert": "ge",
"expect": 200,
"msg": "check status code"
},
{
"check": "status_code",
"assert": "le",
"expect": 200,
"msg": "check status code"
},
{
"check": "status_code",
"assert": "ne",
"expect": 199,
"msg": "check status code"
},
{
"check": "body.args.foo",
"assert": "contains",
"expect": "happy",
"msg": "check status code"
},
{
"check": "body.args.foo",
"assert": "type_match",
"expect": "string",
"msg": "check status code"
},
{
"check": "body.args.foo",
"assert": "starts_with",
"expect": "I'm",
"msg": "check status code"
},
{
"check": "body.args.foo",
"assert": "type_match",
"expect": "string",
"msg": "check status code"
}
]
}

207
report.html Normal file
View File

@@ -0,0 +1,207 @@
<head>
<meta content="text/html; charset=utf-8" http-equiv="content-type"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TestReport</title>
<style>
body {
background-color: #f2f2f2;
color: #333;
margin: 0 auto;
width: 960px;
}
#summary {
width: 960px;
margin-bottom: 20px;
}
#summary th {
background-color: skyblue;
padding: 5px 12px;
}
#summary td {
background-color: lightblue;
text-align: center;
padding: 4px 8px;
}
.details {
width: 960px;
margin-bottom: 20px;
}
.details th {
background-color: skyblue;
padding: 5px 12px;
}
.details tr .passed {
background-color: lightgreen;
}
.details tr .failed {
background-color: red;
}
.details tr .unchecked {
background-color: gray;
}
.details td {
background-color: lightblue;
padding: 5px 12px;
}
.details .detail {
background-color: lightgrey;
font-size: smaller;
padding: 5px 10px;
line-height: 20px;
text-align: left;
}
.details .success {
background-color: greenyellow;
}
.details .error {
background-color: red;
}
.details .failure {
background-color: salmon;
}
.details .skipped {
background-color: gray;
}
.button {
font-size: 1em;
padding: 6px;
width: 4em;
text-align: center;
background-color: #06d85f;
border-radius: 20px/50px;
cursor: pointer;
transition: all 0.3s ease-out;
}
a.button {
color: gray;
text-decoration: none;
display: inline-block;
}
.button:hover {
background: #2cffbd;
}
.overlay {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(0, 0, 0, 0.7);
transition: opacity 500ms;
visibility: hidden;
opacity: 0;
line-height: 25px;
}
.overlay:target {
visibility: visible;
opacity: 1;
}
.popup {
margin: 70px auto;
padding: 20px;
background: #fff;
border-radius: 10px;
width: 50%;
position: relative;
transition: all 3s ease-in-out;
}
.popup h2 {
margin-top: 0;
color: #333;
font-family: Tahoma, Arial, sans-serif;
}
.popup .close {
position: absolute;
top: 20px;
right: 30px;
transition: all 200ms;
font-size: 30px;
font-weight: bold;
text-decoration: none;
color: #333;
}
.popup .close:hover {
color: #06d85f;
}
.popup .content {
max-height: 80%;
overflow: auto;
text-align: left;
}
.popup .separator {
color: royalblue
}
@media screen and (max-width: 700px) {
.box {
width: 70%;
}
.popup {
width: 70%;
}
}
</style>
</head>
<body>
<h1>API Test Report</h1>
<h2>Summary</h2>
<table id="summary">
<tr>
<th>START AT</th>
<td colspan="4">2022-02-14 14:39:40.220096 &#43;0800 CST m=&#43;16.010080077</td>
</tr>
<tr>
<th>DURATION</th>
<td colspan="4">0 seconds</td>
</tr>
<tr>
<th>PLATFORM</th>
<td>HttpRunnerPlus v0.6.0</td>
<td>go1.16.8</td>
<td colspan="2">darwin-amd64</td>
</tr>
<tr>
<th>STAT</th>
<th colspan="2">TESTCASES (success/fail)</th>
<th colspan="2">TESTSTEPS (success/fail/error/skip)</th>
</tr>
<tr>
<td>total (details) =></td>
<td colspan="2">0 (0/0)</td>
<td colspan="2">0 (0/0/0/0)</td>
</tr>
</table>
<h2>Details</h2>
</body>

View File

@@ -117,7 +117,7 @@ func (v *responseObject) Validate(validators []Validator, variablesMapping map[s
assertMethod := validator.Assert
assertFunc, ok := builtin.Assertions[assertMethod]
if !ok {
return errors.New(fmt.Sprintf("unexpected assertion method: %v", assertMethod))
return errors.New(fmt.Sprintf("unexpected assertMethod: %v", assertMethod))
}
// parse expected value
@@ -151,10 +151,10 @@ func (v *responseObject) Validate(validators []Validator, variablesMapping map[s
if !result {
v.t.Fail()
return errors.New(fmt.Sprintf(
"do assertion failed, assertMethod: %v, expectValue: %v, checkValue: %v",
"do assertion failed, assertMethod: %v, checkValue: %v, expectValue: %v",
assertMethod,
expectValue,
checkValue,
expectValue,
))
}
}

View File

@@ -126,7 +126,7 @@ func (s *StepRequestValidation) AssertRegexp(jmesPath string, expected interface
func (s *StepRequestValidation) AssertStartsWith(jmesPath string, expected interface{}, msg string) *StepRequestValidation {
v := Validator{
Check: jmesPath,
Assert: "startswith",
Assert: "starts_with",
Expect: expected,
Message: msg,
}
@@ -137,7 +137,7 @@ func (s *StepRequestValidation) AssertStartsWith(jmesPath string, expected inter
func (s *StepRequestValidation) AssertEndsWith(jmesPath string, expected interface{}, msg string) *StepRequestValidation {
v := Validator{
Check: jmesPath,
Assert: "endswith",
Assert: "ends_with",
Expect: expected,
Message: msg,
}