feat: support retry when test step failed

This commit is contained in:
duanchao.bill
2022-04-06 20:53:32 +08:00
committed by debugtalk
parent 5e40e3692d
commit 596e6673fe
9 changed files with 96 additions and 8 deletions

View File

@@ -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()

View File

@@ -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
View 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