Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
API-Automation
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
文鑫
API-Automation
Commits
1251b0e3
Commit
1251b0e3
authored
Jul 06, 2020
by
文鑫
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加获取用例severity的方法
parent
4714866b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
17 deletions
+27
-17
TestCase/test_Source.py
+27
-17
No files found.
TestCase/test_Source.py
View file @
1251b0e3
...
@@ -5,35 +5,47 @@ import requests
...
@@ -5,35 +5,47 @@ import requests
import
allure
import
allure
import
pytest
import
pytest
import
sys
import
sys
import
test
sys
.
path
.
append
(
'../'
)
sys
.
path
.
append
(
'../'
)
from
common
import
getSourceId
from
common
import
getSourceId
from
common.getData
import
DoExcelByPandas
from
common.getData
import
DoExcelByPandas
@allure.feature
(
'数据源'
)
@allure.feature
(
'数据源'
)
class
TestSource
():
class
TestSource
():
'''
@allure.severity装饰器按严重性级别来标记case
执行指定测试用例 --allure-severities blocker
BLOCKER = 'blocker' 阻塞缺陷
CRITICAL = 'critical' 严重缺陷
NORMAL = 'normal' 一般缺陷
MINOR = 'minor' 次要缺陷
TRIVIAL = 'trivial' 轻微缺陷
'''
parametrize
=
DoExcelByPandas
()
.
get_data_for_pytest
(
'../data/DataA_Source.xlsx'
,
'Sheet1'
)
parametrize
=
DoExcelByPandas
()
.
get_data_for_pytest
(
'../data/DataA_Source.xlsx'
,
'Sheet1'
)
@allure.title
(
'{story}'
)
severity
=
DoExcelByPandas
()
.
get_data_for_allure
(
'../data/DataA_Source.xlsx'
,
'Sheet1'
)
@pytest.mark.parametrize
(
'id,url,data,story,method,severity,condition,except_result'
,
parametrize
)
print
(
severity
)
def
test
(
self
,
id
,
url
,
data
,
story
,
method
,
severity
,
condition
,
except_result
):
# test开头的测试函数
@allure.severity
(
severity
)
url
=
url
@allure.title
(
'{title}'
)
#测试删除数据源接口
@pytest.mark.parametrize
(
'id,url,data,title,method,severity,condition,except_result'
,
parametrize
)
if
story
==
'删除mysql数据源'
or
story
==
'删除oracle数据源'
:
def
test
(
self
,
id
,
url
,
data
,
title
,
method
,
severity
,
condition
,
except_result
):
# test开头的测试函数
# 测试删除数据源接口
if
title
==
'删除mysql数据源'
or
title
==
'删除oracle数据源'
:
id
=
getSourceId
.
get_SourceId
(
data
)
id
=
getSourceId
.
get_SourceId
(
data
)
#将数据源id拼接在url地址上
#
将数据源id拼接在url地址上
url
=
url
+
id
url
=
url
+
id
r
=
requests
.
post
(
url
=
url
)
r
=
requests
.
post
(
url
=
url
)
#测试需要传递dataSourceId的接口
#
测试需要传递dataSourceId的接口
elif
'dataSourceId'
in
story
:
elif
'dataSourceId'
in
title
:
id
=
getSourceId
.
get_SourceId
(
data
)
id
=
getSourceId
.
get_SourceId
(
data
)
url
=
url
+
id
url
=
url
+
id
r
=
requests
.
get
(
url
=
url
)
r
=
requests
.
get
(
url
=
url
)
#测试post接口
#
测试post接口
elif
method
==
'post'
:
elif
method
==
'post'
:
json
=
eval
(
data
)
#
eval返回传入字符串的表达式的结果
json
=
eval
(
data
)
#
eval返回传入字符串的表达式的结果
r
=
requests
.
post
(
url
=
url
,
json
=
json
)
r
=
requests
.
post
(
url
=
url
,
json
=
json
)
#测试get接口
#
测试get接口
elif
method
==
'get'
:
elif
method
==
'get'
:
r
=
requests
.
get
(
url
=
url
)
r
=
requests
.
get
(
url
=
url
)
response
=
r
.
json
()
response
=
r
.
json
()
...
@@ -42,6 +54,4 @@ class TestSource():
...
@@ -42,6 +54,4 @@ class TestSource():
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
pytest
.
main
([
'-s'
,
'test_Source.py'
])
#-s参数是为了显示用例的打印信息。 -q参数只显示结果,不显示过程
pytest
.
main
([
'-s'
,
'test_Source.py'
])
# -s参数是为了显示用例的打印信息。 -q参数只显示结果,不显示过程
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment