Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
InterfaceAutoTest
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
TestAuto
InterfaceAutoTest
Commits
3cdc4811
Commit
3cdc4811
authored
May 06, 2021
by
jiaqiying
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
根据传入的产品名来运行对应产品的测试用例
parent
13cae9ed
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
7 deletions
+33
-7
common/tools.py
+10
-3
config.py
+5
-2
run.py
+18
-2
test_case/bmc/__init__.py
+0
-0
No files found.
common/tools.py
View file @
3cdc4811
...
...
@@ -3,7 +3,7 @@
import
json
import
logging
import
requests
from
config
import
BaseConfig
from
config
import
BaseConfig
,
BMCConfig
def
request_main
(
url
,
headers
,
method
,
data
):
...
...
@@ -28,4 +28,11 @@ def request_main(url, headers, method, data):
if
res
!=
None
:
return
res
.
json
()
return
res
\ No newline at end of file
return
res
def
get_case_dir
(
product_name
):
test_case_dir
=
BaseConfig
.
default_test_case_dir
if
product_name
==
BMCConfig
.
name
:
test_case_dir
=
BMCConfig
.
test_case_dir
return
test_case_dir
\ No newline at end of file
config.py
View file @
3cdc4811
...
...
@@ -5,12 +5,15 @@ class BaseConfig():
# 请求头
headers
=
{
'Content-Type'
:
'application/json; charset=utf-8'
}
# 当前运行的产品名
current_product
=
""
current_product
=
"bmc"
default_test_case_dir
=
"test_case/bmc/"
class
BMCConfig
(
BaseConfig
):
"""斑马信用app的配置类"""
pass
# 测试用例目录
name
=
"bmc"
test_case_dir
=
"test_case/bmc/"
class
DingTalk
(
BaseConfig
):
...
...
run.py
View file @
3cdc4811
#coding:utf-8
import
os
import
pytest
import
argparse
from
config
import
BaseConfig
from
common.tools
import
get_case_dir
def
get_parser
():
parser
=
argparse
.
ArgumentParser
(
description
=
"Demo of argparse"
)
parser
.
add_argument
(
'--product'
,
type
=
str
,
default
=
BaseConfig
.
current_product
)
return
parser
if
__name__
==
"__main__"
:
parser
=
get_parser
()
args
=
get_parser
()
# 获取要执行的产品的用例目录
test_case_dir
=
get_case_dir
(
args
.
product
)
#删除之前报告
for
one
in
os
.
listdir
(
'../report/tmp'
):
if
'json'
in
one
:
os
.
remove
(
f
'../report/tmp/{one}'
)
# 生成报告数据
pytest
.
main
([
'-s'
,
'--alluredir'
,
'../report/tmp'
])
pytest
.
main
([
'-v'
,
'-s'
,
test_case_dir
,
'--alluredir'
,
'../report/tmp'
])
# 打开报告
os
.
system
(
'allure serve ../report/tmp'
)
\ No newline at end of file
test_case/bmc/__init__.py
0 → 100644
View file @
3cdc4811
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