-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: #1146 add error retry support
- Loading branch information
1 parent
e75f1b0
commit 46e95a7
Showing
11 changed files
with
144 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import re | ||
import sys | ||
from httprunner.cli import main | ||
|
||
|
||
if __name__ == '__main__': | ||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) | ||
sys.argv.append("run") | ||
sys.argv.append("--verbose") | ||
# sys.argv.append("request_methods/request_with_extract.yml") | ||
sys.argv.append("request_methods/request_with_testcase_validate.yml") | ||
print(sys.argv) | ||
sys.exit(main()) |
11 changes: 11 additions & 0 deletions
11
examples/postman_echo/request_methods/request_with_testcase_errorretry.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
config: | ||
name: "request testcase: with error retry" | ||
base_url: "https://postman-echo.com" | ||
|
||
teststeps: | ||
- | ||
name: get with params | ||
testcase: request_methods/request_with_teststep_errorretry.yml | ||
retry: | ||
tries: 3 | ||
delay: 5 |
34 changes: 34 additions & 0 deletions
34
examples/postman_echo/request_methods/request_with_testcase_errorretry_test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# NOTE: Generated By HttpRunner v3.1.6 | ||
# FROM: request_methods/request_with_testcase_errorretry.yml | ||
|
||
|
||
import sys | ||
from pathlib import Path | ||
|
||
sys.path.insert(0, str(Path(__file__).parent.parent)) | ||
|
||
|
||
from httprunner import HttpRunner, Config, Step, RunRequest, RunTestCase | ||
|
||
from request_methods.request_with_teststep_errorretry_test import ( | ||
TestCaseRequestWithTeststepErrorretry as RequestWithTeststepErrorretry, | ||
) | ||
|
||
|
||
class TestCaseRequestWithTestcaseErrorretry(HttpRunner): | ||
|
||
config = Config("request testcase: with error retry").base_url( | ||
"https://postman-echo.com" | ||
) | ||
|
||
teststeps = [ | ||
Step( | ||
RunTestCase("get with params") | ||
.with_retry(tries=3, delay=5) | ||
.call(RequestWithTeststepErrorretry) | ||
), | ||
] | ||
|
||
|
||
if __name__ == "__main__": | ||
TestCaseRequestWithTestcaseErrorretry().test_start() |
22 changes: 22 additions & 0 deletions
22
examples/postman_echo/request_methods/request_with_teststep_errorretry.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
config: | ||
name: "request teststep: with error retry" | ||
base_url: "https://postman-echo.com" | ||
|
||
teststeps: | ||
- | ||
name: get with params | ||
request: | ||
method: GET | ||
url: /get | ||
params: | ||
info: "ip" | ||
headers: | ||
User-Agent: HttpRunner/${get_httprunner_version()} | ||
retry: | ||
tries: 3 | ||
delay: 5 | ||
validate: | ||
- eq: ["status_code", 200] | ||
- eq: ["body.args.foo1", "bar11"] | ||
- eq: ["body.args.sum_v", "3"] | ||
- eq: ["body.args.foo2", "bar21"] |
31 changes: 31 additions & 0 deletions
31
examples/postman_echo/request_methods/request_with_teststep_errorretry_test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# NOTE: Generated By HttpRunner v3.1.6 | ||
# FROM: request_methods/request_with_teststep_errorretry.yml | ||
|
||
|
||
from httprunner import HttpRunner, Config, Step, RunRequest, RunTestCase | ||
|
||
|
||
class TestCaseRequestWithTeststepErrorretry(HttpRunner): | ||
|
||
config = Config("request teststep: with error retry").base_url( | ||
"https://postman-echo.com" | ||
) | ||
|
||
teststeps = [ | ||
Step( | ||
RunRequest("get with params") | ||
.with_retry(tries=3, delay=5) | ||
.get("/get") | ||
.with_params(**{"info": "ip"}) | ||
.with_headers(**{"User-Agent": "HttpRunner/${get_httprunner_version()}"}) | ||
.validate() | ||
.assert_equal("status_code", 200) | ||
.assert_equal("body.args.foo1", "bar11") | ||
.assert_equal("body.args.sum_v", "3") | ||
.assert_equal("body.args.foo2", "bar21") | ||
), | ||
] | ||
|
||
|
||
if __name__ == "__main__": | ||
TestCaseRequestWithTeststepErrorretry().test_start() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters