mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-14 20:08:23 +08:00
feat: support retry when test step failed
This commit is contained in:
@@ -23,3 +23,20 @@ def get_app_version():
|
||||
|
||||
def calculate_two_nums(a, b=1):
|
||||
return [a + b, b - a]
|
||||
|
||||
|
||||
def fake_rand_count():
|
||||
"""
|
||||
return 1 at first call
|
||||
return 2 at second call
|
||||
"""
|
||||
l = []
|
||||
|
||||
def func():
|
||||
l.append(1)
|
||||
return len(l)
|
||||
|
||||
return func
|
||||
|
||||
|
||||
fake_randnum = fake_rand_count()
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
|
||||
@Date : 2022/4/7
|
||||
@File : request_with_retry.py
|
||||
@Author : duanchao.bill
|
||||
@Desc :
|
||||
|
||||
"""
|
||||
|
||||
from httprunner import HttpRunner, Config, Step, RunRequest, RunTestCase
|
||||
|
||||
|
||||
class TestCaseRetry(HttpRunner):
|
||||
config = (
|
||||
Config("request methods testcase in hardcode")
|
||||
.base_url("https://postman-echo.com")
|
||||
.verify(False)
|
||||
)
|
||||
|
||||
teststeps = [
|
||||
Step(
|
||||
RunRequest("run with retry")
|
||||
.with_retry(retry_times=1, retry_interval=1)
|
||||
.get("/get")
|
||||
.with_params(**{"foo1": "${fake_randnum()}"})
|
||||
.with_headers(**{"User-Agent": "HttpRunner/3.0"})
|
||||
.validate()
|
||||
.assert_equal("body.args.foo1", "2")
|
||||
)
|
||||
]
|
||||
6
examples/pytest.ini
Normal file
6
examples/pytest.ini
Normal file
@@ -0,0 +1,6 @@
|
||||
[pytest]
|
||||
addopts = -s
|
||||
# https://docs.pytest.org/en/latest/how-to/output.html
|
||||
junit_logging = all
|
||||
junit_duration_report = total
|
||||
log_cli = False
|
||||
Reference in New Issue
Block a user