定义失败重跑机制
This commit is contained in:
parent
4fdc37973a
commit
783cc24e6b
|
@ -62,4 +62,6 @@ lark:
|
||||||
webhook:
|
webhook:
|
||||||
|
|
||||||
|
|
||||||
|
# 定义重跑参数
|
||||||
|
reruns: 3
|
||||||
|
reruns_delay: 3
|
|
@ -150,5 +150,5 @@ platform_goods_total_05:
|
||||||
dependence_case_data:
|
dependence_case_data:
|
||||||
|
|
||||||
assert:
|
assert:
|
||||||
status_code: 200
|
status_code: 404
|
||||||
sql:
|
sql:
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# @Time : 2023-02-24 16:59:44
|
# @Time : 2023-03-10 11:03:09
|
||||||
|
|
||||||
|
|
||||||
import allure
|
import allure
|
||||||
|
@ -21,6 +21,7 @@ re_data = regular(str(TestData))
|
||||||
@allure.feature("上传接口")
|
@allure.feature("上传接口")
|
||||||
class TestUploadFile:
|
class TestUploadFile:
|
||||||
|
|
||||||
|
@pytest.mask.flaky(reruns=3, reruns_delay=3)
|
||||||
@allure.story("上传接口")
|
@allure.story("上传接口")
|
||||||
@pytest.mark.parametrize('in_data', eval(re_data), ids=[i['detail'] for i in TestData])
|
@pytest.mark.parametrize('in_data', eval(re_data), ids=[i['detail'] for i in TestData])
|
||||||
def test_upload_file(self, in_data, case_skip):
|
def test_upload_file(self, in_data, case_skip):
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# @Time : 2023-02-24 16:59:45
|
# @Time : 2023-03-10 11:03:09
|
||||||
|
|
||||||
|
|
||||||
import allure
|
import allure
|
||||||
import pytest
|
import pytest
|
||||||
|
@ -10,7 +9,7 @@ from utils.assertion.assert_control import Assert
|
||||||
from utils.requests_tool.request_control import RequestControl
|
from utils.requests_tool.request_control import RequestControl
|
||||||
from utils.read_files_tools.regular_control import regular
|
from utils.read_files_tools.regular_control import regular
|
||||||
from utils.requests_tool.teardown_control import TearDownHandler
|
from utils.requests_tool.teardown_control import TearDownHandler
|
||||||
|
import pytest_rerunfailures
|
||||||
|
|
||||||
case_id = ['platform_index_01', 'platform_property_02', 'platform_goods_list_03', 'platform_goods_comment_04', 'platform_goods_total_05']
|
case_id = ['platform_index_01', 'platform_property_02', 'platform_goods_list_03', 'platform_goods_comment_04', 'platform_goods_total_05']
|
||||||
TestData = GetTestCase.case_data(case_id)
|
TestData = GetTestCase.case_data(case_id)
|
||||||
|
@ -22,6 +21,7 @@ re_data = regular(str(TestData))
|
||||||
class TestPlatformIndex:
|
class TestPlatformIndex:
|
||||||
|
|
||||||
@allure.story("商城模块")
|
@allure.story("商城模块")
|
||||||
|
@pytest.mark.flaky(reruns=3, reruns_delay=3)
|
||||||
@pytest.mark.parametrize('in_data', eval(re_data), ids=[i['detail'] for i in TestData])
|
@pytest.mark.parametrize('in_data', eval(re_data), ids=[i['detail'] for i in TestData])
|
||||||
def test_platform_index(self, in_data, case_skip):
|
def test_platform_index(self, in_data, case_skip):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# @Time : 2023-02-24 16:59:45
|
# @Time : 2023-03-10 11:03:09
|
||||||
|
|
||||||
|
|
||||||
import allure
|
import allure
|
||||||
|
@ -21,6 +21,7 @@ re_data = regular(str(TestData))
|
||||||
@allure.feature("登录模块")
|
@allure.feature("登录模块")
|
||||||
class TestLogin:
|
class TestLogin:
|
||||||
|
|
||||||
|
@pytest.mask.flaky(reruns=3, reruns_delay=3)
|
||||||
@allure.story("登录")
|
@allure.story("登录")
|
||||||
@pytest.mark.parametrize('in_data', eval(re_data), ids=[i['detail'] for i in TestData])
|
@pytest.mark.parametrize('in_data', eval(re_data), ids=[i['detail'] for i in TestData])
|
||||||
def test_login(self, in_data, case_skip):
|
def test_login(self, in_data, case_skip):
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# @Time : 2023-02-24 16:59:45
|
# @Time : 2023-03-10 11:03:09
|
||||||
|
|
||||||
|
|
||||||
import allure
|
import allure
|
||||||
|
@ -21,6 +21,7 @@ re_data = regular(str(TestData))
|
||||||
@allure.feature("登录模块")
|
@allure.feature("登录模块")
|
||||||
class TestUserInfo:
|
class TestUserInfo:
|
||||||
|
|
||||||
|
@pytest.mask.flaky(reruns=3, reruns_delay=3)
|
||||||
@allure.story("用户信息")
|
@allure.story("用户信息")
|
||||||
@pytest.mark.parametrize('in_data', eval(re_data), ids=[i['detail'] for i in TestData])
|
@pytest.mark.parametrize('in_data', eval(re_data), ids=[i['detail'] for i in TestData])
|
||||||
def test_user_info(self, in_data, case_skip):
|
def test_user_info(self, in_data, case_skip):
|
||||||
|
|
|
@ -14,6 +14,9 @@ class NotificationType(Enum):
|
||||||
FEI_SHU = 4
|
FEI_SHU = 4
|
||||||
|
|
||||||
|
|
||||||
|
# dataclass 提供一个简便的方式创建数据类, 默认实现__init__(), __repr__(), __eq__()方法.
|
||||||
|
# dataclass支持数据类型的嵌套
|
||||||
|
# 支持将数据设置为不可变
|
||||||
@dataclass
|
@dataclass
|
||||||
class TestMetrics:
|
class TestMetrics:
|
||||||
""" 用例执行数据 """
|
""" 用例执行数据 """
|
||||||
|
@ -225,6 +228,7 @@ class AllureAttachmentType(Enum):
|
||||||
|
|
||||||
PDF = "pdf"
|
PDF = "pdf"
|
||||||
|
|
||||||
|
|
||||||
@unique
|
@unique
|
||||||
class AssertMethod(Enum):
|
class AssertMethod(Enum):
|
||||||
"""断言类型"""
|
"""断言类型"""
|
||||||
|
@ -244,3 +248,8 @@ class AssertMethod(Enum):
|
||||||
contained_by = 'contained_by'
|
contained_by = 'contained_by'
|
||||||
startswith = 'startswith'
|
startswith = 'startswith'
|
||||||
endswith = 'endswith'
|
endswith = 'endswith'
|
||||||
|
|
||||||
|
|
||||||
|
class Reruns(BaseModel):
|
||||||
|
reruns: int
|
||||||
|
reruns_delay: int
|
||||||
|
|
|
@ -40,7 +40,8 @@ def write_testcase_file(*, allure_epic, allure_feature, class_title,
|
||||||
now = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
now = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||||
# 设置为True的时候,修改yaml文件的用例,代码中的内容会实时更新
|
# 设置为True的时候,修改yaml文件的用例,代码中的内容会实时更新
|
||||||
real_time_update_test_cases = conf_data['real_time_update_test_cases']
|
real_time_update_test_cases = conf_data['real_time_update_test_cases']
|
||||||
|
reruns = conf_data['reruns']
|
||||||
|
reruns_delay = conf_data['reruns_delay']
|
||||||
page = f'''#!/usr/bin/env python
|
page = f'''#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# @Time : {now}
|
# @Time : {now}
|
||||||
|
@ -64,6 +65,7 @@ re_data = regular(str(TestData))
|
||||||
@allure.feature("{allure_feature}")
|
@allure.feature("{allure_feature}")
|
||||||
class Test{class_title}:
|
class Test{class_title}:
|
||||||
|
|
||||||
|
@pytest.mark.flaky(reruns={reruns}, reruns_delay={reruns_delay})
|
||||||
@allure.story("{allure_story}")
|
@allure.story("{allure_story}")
|
||||||
@pytest.mark.parametrize('in_data', eval(re_data), ids=[i['detail'] for i in TestData])
|
@pytest.mark.parametrize('in_data', eval(re_data), ids=[i['detail'] for i in TestData])
|
||||||
def test_{func_title}(self, in_data, case_skip):
|
def test_{func_title}(self, in_data, case_skip):
|
||||||
|
|
|
@ -15,6 +15,7 @@ import urllib3
|
||||||
from requests_toolbelt import MultipartEncoder
|
from requests_toolbelt import MultipartEncoder
|
||||||
from common.setting import ensure_path_sep
|
from common.setting import ensure_path_sep
|
||||||
from utils.logging_tool.log_control import ERROR
|
from utils.logging_tool.log_control import ERROR
|
||||||
|
from utils.other_tools.exceptions import ValueNotFoundError
|
||||||
from utils.other_tools.models import RequestType
|
from utils.other_tools.models import RequestType
|
||||||
from utils.logging_tool.log_decorator import log_decorator
|
from utils.logging_tool.log_decorator import log_decorator
|
||||||
from utils.mysql_tool.mysql_control import AssertExecution
|
from utils.mysql_tool.mysql_control import AssertExecution
|
||||||
|
@ -48,8 +49,8 @@ class RequestControl:
|
||||||
_data = self.__yaml_case.data
|
_data = self.__yaml_case.data
|
||||||
for key, value in ast.literal_eval(cache_regular(str(_data)))['data'].items():
|
for key, value in ast.literal_eval(cache_regular(str(_data)))['data'].items():
|
||||||
file_data[key] = value
|
file_data[key] = value
|
||||||
except KeyError:
|
except KeyError as exc:
|
||||||
...
|
raise ValueNotFoundError("{data}数据未找到,请检查yaml文件是否添加") from exc
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def multipart_data(
|
def multipart_data(
|
||||||
|
|
Loading…
Reference in New Issue