Commit df298aa8 by lin

update test_case.py

parent 576bd596
......@@ -8,6 +8,7 @@
#
# ---------------------------------------------------------------------------
import openpyxl
from openpyxl.styles.builtins import title
from APITest_1226 import log
from APITest_1226.common.read_basic_ini import ReadBasicIni
......@@ -47,6 +48,16 @@ class ReadExcel:
return self.__get_value("b",row)
@log
def title_name(self, row):
"""获取用例标题"""
return self.__get_value("d", row)
@log
def level_name(self, row):
"""获取用例级别"""
return self.__get_value("e", row)
@log
def api_name(self, row):
"""获取接口名称"""
return self.__get_value("c", row)
......@@ -123,8 +134,12 @@ class ReadExcel:
sql = self.sql_data1(row)
sql_type = self.sql_type(row)
update_key = self.update_key(row)
level = self.level_name(row)
title_name = self.title_name(row)
module = self.module_name(row)
api = self.api_name(row)
if url is not None and expect is not None and req is not None:
case_dict.append([url,mime,req,case,expect,sql,sql_type,update_key])
case_dict.append([url,mime,req,case,expect,sql,sql_type,update_key,level,title_name,module,api])
return case_dict
......@@ -133,7 +148,7 @@ class ReadExcel:
if __name__ == '__main__':
res = ReadExcel("lisi")
print(res.case_dict())
print(res.case_url(3))
# print(res.case_url(3))
......
......@@ -8,9 +8,9 @@
#
# ---------------------------------------------------------------------------
# """直接复制,不要做任何改动,必须放在用例层目录下的conftest.py文件类"""
# def pytest_collection_modifyitems(items):
# # item表示每个测试用例,解决用例名称中文显示问题
# for item in items:
# item.name = item.name.encode("utf-8").decode("unicode-escape")
# item._nodeid = item._nodeid.encode("utf-8").decode("unicode-escape")
\ No newline at end of file
"""直接复制,不要做任何改动,必须放在用例层目录下的conftest.py文件类"""
def pytest_collection_modifyitems(items):
# item表示每个测试用例,解决用例名称中文显示问题
for item in items:
item.name = item.name.encode("utf-8").decode("unicode-escape")
item._nodeid = item._nodeid.encode("utf-8").decode("unicode-escape")
\ No newline at end of file
......@@ -7,19 +7,33 @@
# Description:
#
# ---------------------------------------------------------------------------
from allure_pytest.utils import allure_label
from APITest_1226 import log
from APITest_1226.common.read_excel import ReadExcel
import pytest
import allure
dict_case = ReadExcel("lisi").case_dict()
class TestBpm:
@log
@pytest.mark.parametrize("url,mime,req,case,expect,sql,sql_type,update_key",dict_case)
def test_bpm(self,req2_fix,url,mime,req,case,expect,sql,sql_type,update_key):
@pytest.mark.parametrize("url,mime,req,case,expect,sql,sql_type,update_key,level,title_name,module,api",dict_case)
def test_bpm(self,req2_fix,url,mime,req,case,expect,sql,sql_type,update_key,level,title_name,module,api):
res = req2_fix.req_all(req_url=url, req_mime=mime, req_req=req, req_case=case,sql_type=sql_type, sql_data=sql, update_key=update_key)
allure.dynamic.feature(module)
allure.dynamic.story(api)
allure.dynamic.title(title_name)
allure.dynamic.severity(level)
try:
for key in expect:
assert res.json().get(key) ==expect[key]
except AssertionError :
raise AssertionError(f"\n\t断言失败:失败的用例为{case},期望数据为:{expect},服务器返回的数据:{res.text}")
except Exception as e:
raise e
if __name__ == '__main__':
......
......@@ -7,6 +7,8 @@
# Description:
#
# ---------------------------------------------------------------------------
import allure
from APITest_1226 import log
from APITest_1226.common.read_excel import ReadExcel
import pytest
......@@ -15,11 +17,20 @@ dict_case = ReadExcel("ww").case_dict()
class TestBpm:
@log
@pytest.mark.parametrize("url,mime,req,case,expect,sql,sql_type,update_key",dict_case)
def test_bpm(self,req2_fix,url,mime,req,case,expect,sql,sql_type,update_key):
@pytest.mark.parametrize("url,mime,req,case,expect,sql,sql_type,update_key,level,title_name,module,api",dict_case)
def test_bpm(self,req2_fix,url,mime,req,case,expect,sql,sql_type,update_key,level,title_name,module,api):
res = req2_fix.req_all(req_url=url, req_mime=mime, req_req=req, req_case=case,sql_type=sql_type, sql_data=sql, update_key=update_key)
allure.dynamic.feature(module)
allure.dynamic.story(api)
allure.dynamic.title(title_name)
allure.dynamic.severity(level)
try:
for key in expect:
assert res.json().get(key) ==expect[key]
assert res.json().get(key) == expect[key]
except AssertionError:
raise AssertionError(f"\n\t断言失败:失败的用例为{case},期望数据为:{expect},服务器返回的数据:{res.text}")
except Exception as e:
raise e
if __name__ == '__main__':
......
......@@ -7,6 +7,8 @@
# Description:
#
# ---------------------------------------------------------------------------
import allure
from APITest_1226 import log
from APITest_1226.common.read_excel import ReadExcel
import pytest
......@@ -15,11 +17,20 @@ dict_case = ReadExcel("zs").case_dict()
class TestBpm:
@log
@pytest.mark.parametrize("url,mime,req,case,expect,sql,sql_type,update_key",dict_case)
def test_bpm(self,req2_fix,url,mime,req,case,expect,sql,sql_type,update_key):
@pytest.mark.parametrize("url,mime,req,case,expect,sql,sql_type,update_key,level,title_name,module,api",dict_case)
def test_bpm(self,req2_fix,url,mime,req,case,expect,sql,sql_type,update_key,level,title_name,module,api):
res = req2_fix.req_all(req_url=url, req_mime=mime, req_req=req, req_case=case,sql_type=sql_type, sql_data=sql, update_key=update_key)
allure.dynamic.feature(module)
allure.dynamic.story(api)
allure.dynamic.title(title_name)
allure.dynamic.severity(level)
try:
for key in expect:
assert res.json().get(key) ==expect[key]
assert res.json().get(key) == expect[key]
except AssertionError:
raise AssertionError(f"\n\t断言失败:失败的用例为{case},期望数据为:{expect},服务器返回的数据:{res.text}")
except Exception as e:
raise e
if __name__ == '__main__':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment