Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
gm-zhuanzhen-test
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
刘丙寅
gm-zhuanzhen-test
Commits
8d6e0dc7
Commit
8d6e0dc7
authored
Mar 05, 2021
by
刘丙寅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码优化 - 变更报告模式。新增日志输出以及新增失败重跑三次。
parent
d18d9645
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
13 deletions
+16
-13
allcase.py
allcase.py
+16
-13
No files found.
allcase.py
View file @
8d6e0dc7
...
@@ -10,6 +10,7 @@ import sys
...
@@ -10,6 +10,7 @@ import sys
import
json
import
json
import
requests
import
requests
import
datetime
import
datetime
from
unittestreport
import
TestRunner
sys
.
path
.
append
(
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))))
sys
.
path
.
append
(
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))))
...
@@ -19,13 +20,6 @@ import sys
...
@@ -19,13 +20,6 @@ import sys
reload(sys)
reload(sys)
sys.setdefaultencoding('utf8')
sys.setdefaultencoding('utf8')
'''
'''
# 这个是优化版执行所有用例并发送报告,分四个步骤
# 第一步加载用例
# 第二步执行用例
# 第三步获取最新测试报告
# 第四步发送邮箱 (这一步不想执行的话,可以注释掉最后面那个函数就行)
# 当前脚本所在文件真实路径
# 当前脚本所在文件真实路径
cur_path
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
cur_path
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
...
@@ -42,7 +36,7 @@ def add_case(caseName="case", rule="case*.py"):
...
@@ -42,7 +36,7 @@ def add_case(caseName="case", rule="case*.py"):
print
(
discover
)
print
(
discover
)
return
discover
return
discover
def
run_case
(
all_case
,
reportName
=
"report"
):
def
run_case
(
all_case
):
'''第二步:执行所有的用例, 并把结果写入HTML测试报告'''
'''第二步:执行所有的用例, 并把结果写入HTML测试报告'''
# now = time.strftime("%Y_%m_%d_%H_%M_%S")
# now = time.strftime("%Y_%m_%d_%H_%M_%S")
...
@@ -74,12 +68,21 @@ def run_case(all_case, reportName="report"):
...
@@ -74,12 +68,21 @@ def run_case(all_case, reportName="report"):
#beautiful report 报告页面效果 要将 本地的那个文件夹放到制定的目录下才行。 python里面的 sitepage里面就行
#beautiful report 报告页面效果 要将 本地的那个文件夹放到制定的目录下才行。 python里面的 sitepage里面就行
# 怎么放进去: 终端 python3 进入后 import sys 随后 sys.path 最后一个路径 回到终端 open 那个路径。 随后将那个文件夹放进去就行。
# 怎么放进去: 终端 python3 进入后 import sys 随后 sys.path 最后一个路径 回到终端 open 那个路径。 随后将那个文件夹放进去就行。
# beautiful report 的一套代码
# beautiful report 的一套代码
from
BeautifulReport
import
BeautifulReport
# from BeautifulReport import BeautifulReport
#
# runner = BeautifulReport(all_case)
#
# runner.report('更美转诊-接口自动化',filename='更美转诊.html',report_dir='report')
#
# return runner.error_count,runner.failure_count
runner
=
BeautifulReport
(
all_case
)
runner
=
TestRunner
(
all_case
,
report_dir
=
"report"
)
runner
.
report
(
'更美转诊-接口自动化'
,
filename
=
'更美转诊.html'
,
report_dir
=
'report'
)
res
=
runner
.
rerun_run
(
count
=
3
,
interval
=
2
)
error
=
res
.
get
(
"error"
)
fail
=
res
.
get
(
"fail"
)
print
(
res
)
return
error
,
fail
return
runner
.
error_count
,
runner
.
failure_count
def
get_report_file
(
report_path
):
def
get_report_file
(
report_path
):
...
@@ -128,7 +131,7 @@ def send_mail(sender, psw, receiver, smtpserver, report_file, port):
...
@@ -128,7 +131,7 @@ def send_mail(sender, psw, receiver, smtpserver, report_file, port):
# 整体调用流程
# 整体调用流程
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
all_case
=
add_case
()
# 1加载用例
all_case
=
add_case
()
# 1加载用例
run_case
(
all_case
)
# 生成测试报告的路径
# 生成测试报告的路径
error_count
,
failure_count
=
run_case
(
all_case
)
# 2执行用例
error_count
,
failure_count
=
run_case
(
all_case
)
# 2执行用例
bug_number
=
int
(
error_count
)
+
int
(
failure_count
)
bug_number
=
int
(
error_count
)
+
int
(
failure_count
)
...
...
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