Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
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
曹燕
Test
Commits
7bad714a
Commit
7bad714a
authored
Nov 25, 2019
by
huangqiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
用例执行相关修改
parent
71a4e837
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
174 additions
and
38 deletions
+174
-38
common.py
Interface_Atuo_test/jiyunying/common.py
+7
-6
config.conf
Interface_Atuo_test/jiyunying/config.conf
+2
-2
dingdingmessage.py
Interface_Atuo_test/jiyunying/dingdingmessage.py
+4
-3
debugtalk.py
Interface_Atuo_test/jiyunying/login/debugtalk.py
+59
-0
debugtalk.py
Interface_Atuo_test/jiyunying/reception/debugtalk.py
+31
-4
run.conf
Interface_Atuo_test/jiyunying/run.conf
+2
-2
run.py
Interface_Atuo_test/jiyunying/run.py
+34
-18
debugtalk.py
Interface_Atuo_test/jiyunying/teach_manage/debugtalk.py
+35
-3
No files found.
Interface_Atuo_test/jiyunying/common.py
View file @
7bad714a
...
@@ -56,19 +56,20 @@ def readconf(section, option, config_path="config.conf"):
...
@@ -56,19 +56,20 @@ def readconf(section, option, config_path="config.conf"):
return
value
return
value
# 获取执行的用例
或用例
路径
# 获取执行的用例
集或用例集
路径
def
get_case_
path
(
section
,
config_path
=
"run.conf"
):
def
get_case_
suites
(
section
,
config_path
=
"run.conf"
):
values
=
[]
case_suites
=
{}
cf
=
configparser
.
ConfigParser
()
cf
=
configparser
.
ConfigParser
()
cf
.
read
(
config_path
,
encoding
=
"utf-8"
)
cf
.
read
(
config_path
,
encoding
=
"utf-8"
)
if
cf
.
has_section
(
section
):
if
cf
.
has_section
(
section
):
items
=
cf
.
items
(
section
)
items
=
cf
.
items
(
section
)
for
item
in
items
:
for
item
in
items
:
value
=
item
[
1
]
name
=
item
[
0
]
values
.
append
(
value
)
path
=
item
[
1
]
case_suites
[
name
]
=
path
else
:
else
:
print
(
"section值错误:"
,
section
)
print
(
"section值错误:"
,
section
)
return
valu
es
return
case_suit
es
# 更新配置文件
# 更新配置文件
...
...
Interface_Atuo_test/jiyunying/config.conf
View file @
7bad714a
...
@@ -9,10 +9,10 @@ reportpath = report/
...
@@ -9,10 +9,10 @@ reportpath = report/
web_hook
=
https
://
oapi
.
dingtalk
.
com
/
robot
/
send
?
access_token
=
94
b76afb5b538437e9986e95bd9e4c882cfcf3c75e8c1b3a6f209cac403b8e00
web_hook
=
https
://
oapi
.
dingtalk
.
com
/
robot
/
send
?
access_token
=
94
b76afb5b538437e9986e95bd9e4c882cfcf3c75e8c1b3a6f209cac403b8e00
[
token
]
[
token
]
token
=
eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9
.
eyJ1aWQiOiIyNTc0ODgiLCJ0ZXJtaW5hbCI6InBjIiwidXVpZCI6Im
MxZmYwYzM0NWU5OTRmZWJhZWRiZTE3YjY4YWE0YmZkIiwidGltZXN0YW1wIjoxNTc0NjY3NzUxMDM4fQ
.
TsobEylOLhkayoGSPWMXy9SrGCrRyFrQ
-
wgX9H7ROi0
token
=
eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9
.
eyJ1aWQiOiIyNTc0ODgiLCJ0ZXJtaW5hbCI6InBjIiwidXVpZCI6Im
JhODZhZGNjZGRiMzQ3ZmViM2IxMmQ2ZTk4MDhhNDQyIiwidGltZXN0YW1wIjoxNTc0NjczMzA1NzQ2fQ
.
CjdjViZs
-
Pi1_7wlMd6xfG4qnZLDSRvn
-
lQX4reL89U
[
password
]
[
password
]
wan_neng_password
=
wan_neng_password
=
A0S7c217137d
-
c92
[
user
]
[
user
]
phone
=
15300000000
phone
=
15300000000
...
...
Interface_Atuo_test/jiyunying/dingdingmessage.py
View file @
7bad714a
...
@@ -51,7 +51,7 @@ def send_dingding_message(web_hook,msg,message_type="text",is_at_all=False,at_mo
...
@@ -51,7 +51,7 @@ def send_dingding_message(web_hook,msg,message_type="text",is_at_all=False,at_mo
def
get_markdown_template
()
->
str
:
def
get_markdown_template
()
->
str
:
markdown_template
=
"""
markdown_template
=
"""
接口测试概要(${host})
\n
${suite_name}
接口测试概要(${host})
\n
是否成功: ${result}
\n
是否成功: ${result}
\n
测试开始时间:${start_datetime}
测试开始时间:${start_datetime}
持续时间:${duration_time}
\n
持续时间:${duration_time}
\n
...
@@ -62,13 +62,14 @@ def get_markdown_template()-> str:
...
@@ -62,13 +62,14 @@ def get_markdown_template()-> str:
return
markdown_template
return
markdown_template
def
send_result_message
(
summary
:
str
):
def
send_result_message
(
summary
:
str
,
suite_name
):
stat
=
summary
[
"stat"
]
stat
=
summary
[
"stat"
]
testcases
=
stat
[
"testcases"
]
testcases
=
stat
[
"testcases"
]
teststeps
=
stat
[
"teststeps"
]
teststeps
=
stat
[
"teststeps"
]
time
=
summary
[
"time"
]
time
=
summary
[
"time"
]
host
=
common
.
readconf
(
"host"
,
"host"
)
host
=
common
.
readconf
(
"host"
,
"host"
)
messagedata
=
{
messagedata
=
{
"suite_name"
:
suite_name
,
"host"
:
host
,
"host"
:
host
,
"result"
:
summary
[
"success"
],
"result"
:
summary
[
"success"
],
"testcases_total"
:
testcases
[
"total"
],
"testcases_total"
:
testcases
[
"total"
],
...
@@ -86,7 +87,7 @@ def send_result_message(summary: str):
...
@@ -86,7 +87,7 @@ def send_result_message(summary: str):
markdown
=
markdown_template
.
safe_substitute
(
**
messagedata
)
markdown
=
markdown_template
.
safe_substitute
(
**
messagedata
)
web_hook
=
common
.
readconf
(
"url"
,
"web_hook"
)
web_hook
=
common
.
readconf
(
"url"
,
"web_hook"
)
msg
=
{
msg
=
{
"title"
:
"接口测试概况"
,
"title"
:
suite_name
+
"接口测试概况"
,
"text"
:
markdown
"text"
:
markdown
}
}
send_dingding_message
(
web_hook
,
msg
=
msg
,
message_type
=
"markdown"
)
send_dingding_message
(
web_hook
,
msg
=
msg
,
message_type
=
"markdown"
)
...
...
Interface_Atuo_test/jiyunying/login/debugtalk.py
View file @
7bad714a
# coding=utf-8
# coding=utf-8
import
time
import
time
from
jiyunying
import
common
from
jiyunying
import
common
import
random
,
json
,
os
def
sleep
(
n_secs
):
def
sleep
(
n_secs
):
...
@@ -14,3 +15,61 @@ def get_host() -> str:
...
@@ -14,3 +15,61 @@ def get_host() -> str:
def
get_wan_neng_password
():
def
get_wan_neng_password
():
return
common
.
readconf
(
"password"
,
"wan_neng_password"
)
return
common
.
readconf
(
"password"
,
"wan_neng_password"
)
def
get_token
():
return
common
.
readconf
(
"token"
,
"token"
)
variables
=
{
"course_name"
:
"测试课程名称"
}
def
get_course_data
():
course_name1
=
common
.
get_time_name
()[
1
]
# print(os.getcwd())
with
open
(
"teach_manage/data/course_data.json"
,
encoding
=
"utf-8"
)
as
fp
:
course_data
=
json
.
load
(
fp
)
course_name2
=
course_data
[
0
][
"courseName"
]
course_name
=
course_name1
+
"_"
+
course_name2
variables
[
"course_name"
]
=
course_name
course_data
[
0
][
"courseName"
]
=
course_name
return
course_data
def
get_course_name
():
return
variables
[
"course_name"
]
def
get_classNo
():
return
common
.
get_time_name
()[
1
]
+
"班"
def
get_student_data
(
attendSchool
,
entrancePaper
=
None
,
introducer
=
None
,
introducerId
=
None
):
num_name
=
random
.
randint
(
0
,
10000
)
student_name
=
"自动"
+
str
(
num_name
)
with
open
(
"reception/data/student_data.json"
,
encoding
=
"utf-8"
)
as
fp
:
student_data
=
json
.
load
(
fp
)
student_data
[
"studentName"
]
=
student_name
student_data
[
"introducer"
]
=
introducer
student_data
[
"introducerId"
]
=
introducerId
student_data
[
"attendSchool"
]
=
attendSchool
student_data
[
"entrancePaper"
]
=
entrancePaper
return
student_data
def
is_skip
():
flag
=
None
host
=
common
.
readconf
(
"host"
,
"host"
)
if
host
==
"geek.jkwljy.com"
:
flag
=
True
else
:
flag
=
False
return
flag
def
get_phone
():
with
open
(
"reception/data/student_data.json"
,
encoding
=
"utf-8"
)
as
fp
:
student_data
=
json
.
load
(
fp
)
phone
=
student_data
[
"studentPrimPhoneNo"
]
return
phone
Interface_Atuo_test/jiyunying/reception/debugtalk.py
View file @
7bad714a
# coding=utf-8
# coding=utf-8
import
time
import
time
from
jiyunying
import
common
from
jiyunying
import
common
import
json
import
random
,
json
,
os
import
os
import
random
def
sleep
(
n_secs
):
def
sleep
(
n_secs
):
time
.
sleep
(
n_secs
)
time
.
sleep
(
n_secs
)
...
@@ -13,10 +12,39 @@ def get_host() -> str:
...
@@ -13,10 +12,39 @@ def get_host() -> str:
return
common
.
set_host
()
return
common
.
set_host
()
def
get_wan_neng_password
():
return
common
.
readconf
(
"password"
,
"wan_neng_password"
)
def
get_token
():
def
get_token
():
return
common
.
readconf
(
"token"
,
"token"
)
return
common
.
readconf
(
"token"
,
"token"
)
variables
=
{
"course_name"
:
"测试课程名称"
}
def
get_course_data
():
course_name1
=
common
.
get_time_name
()[
1
]
# print(os.getcwd())
with
open
(
"teach_manage/data/course_data.json"
,
encoding
=
"utf-8"
)
as
fp
:
course_data
=
json
.
load
(
fp
)
course_name2
=
course_data
[
0
][
"courseName"
]
course_name
=
course_name1
+
"_"
+
course_name2
variables
[
"course_name"
]
=
course_name
course_data
[
0
][
"courseName"
]
=
course_name
return
course_data
def
get_course_name
():
return
variables
[
"course_name"
]
def
get_classNo
():
return
common
.
get_time_name
()[
1
]
+
"班"
def
get_student_data
(
attendSchool
,
entrancePaper
=
None
,
introducer
=
None
,
introducerId
=
None
):
def
get_student_data
(
attendSchool
,
entrancePaper
=
None
,
introducer
=
None
,
introducerId
=
None
):
num_name
=
random
.
randint
(
0
,
10000
)
num_name
=
random
.
randint
(
0
,
10000
)
student_name
=
"自动"
+
str
(
num_name
)
student_name
=
"自动"
+
str
(
num_name
)
...
@@ -45,4 +73,3 @@ def get_phone():
...
@@ -45,4 +73,3 @@ def get_phone():
student_data
=
json
.
load
(
fp
)
student_data
=
json
.
load
(
fp
)
phone
=
student_data
[
"studentPrimPhoneNo"
]
phone
=
student_data
[
"studentPrimPhoneNo"
]
return
phone
return
phone
Interface_Atuo_test/jiyunying/run.conf
View file @
7bad714a
[
test
]
[
test
]
login
=
login
/
testsuites
/
login
.
yml
login
=
login
/
testsuites
/
login
.
yml
#
student_new
=
reception
/
testsuites
/
apply_stuent_new
.
yml
student_new
=
reception
/
testsuites
/
apply_stuent_new
.
yml
\ No newline at end of file
\ No newline at end of file
Interface_Atuo_test/jiyunying/run.py
View file @
7bad714a
...
@@ -6,39 +6,55 @@ import common
...
@@ -6,39 +6,55 @@ import common
import
getdata
import
getdata
from
sendemail
import
SendEmail
from
sendemail
import
SendEmail
def
run
():
class
Main
:
def
__init__
(
self
):
self
.
set_conf
()
def
set_conf
(
self
):
common
.
update_address
(
sys
.
argv
)
gd
=
getdata
.
GetData
()
phone
=
common
.
readconf
(
"user"
,
"phone"
)
password
=
common
.
readconf
(
"user"
,
"password"
)
# gd.set_token(phone, password)
gd
.
set_wan_neng_password
(
phone
,
password
)
def
run
(
self
,
suite_name
,
suite_path
):
report_path
=
common
.
readconf
(
"path"
,
"reportpath"
)
report_path
=
common
.
readconf
(
"path"
,
"reportpath"
)
logfile_name
=
common
.
get_time_name
()[
0
]
+
"_interface_test.log"
logfile_name
=
common
.
get_time_name
()[
0
]
+
"_interface_test.log"
log_path
=
common
.
readconf
(
"path"
,
"logpath"
)
+
logfile_name
log_path
=
common
.
readconf
(
"path"
,
"logpath"
)
+
logfile_name
report_name
=
common
.
get_time_name
()[
1
]
+
"_interface_test.html"
report_name
=
common
.
get_time_name
()[
1
]
+
suite_name
+
"_interface_test.html"
runner
=
HttpRunner
(
report_dir
=
report_path
,
log_level
=
"INFO"
,
runner
=
HttpRunner
(
report_dir
=
report_path
,
log_level
=
"INFO"
,
log_file
=
log_path
,
report_file
=
report_name
,
failfast
=
True
)
log_file
=
log_path
,
report_file
=
report_name
,
failfast
=
True
)
# 测试用例路径
path_or_testcases
=
common
.
get_case_path
(
"test"
)
# dot_env_path = ""
# dot_env_path = ""
# 变量映射,可用于对传入测试用例中的变量进行覆盖替换。
# 变量映射,可用于对传入测试用例中的变量进行覆盖替换。
# mapping=override_mapping
# mapping=override_mapping
for
test_case_path
in
path_or_testcases
:
try
:
runner
.
run
(
test_case_path
)
runner
.
run
(
suite_path
)
# dingdingmessage.send_result_message(runner.summary)
except
Exception
as
e
:
print
(
"用例集执行失败"
,
e
)
try
:
dingdingmessage
.
send_result_message
(
runner
.
summary
,
suite_name
)
except
Exception
as
e
:
print
(
"钉钉消息发送失败"
,
e
)
try
:
send_email
=
SendEmail
()
send_email
=
SendEmail
()
subject
=
common
.
get_time_name
()[
0
]
+
"接口测试报告"
subject
=
common
.
get_time_name
()[
0
]
+
suite_name
+
"接口测试报告"
attachments
=
[]
attachments
=
[]
attachment
=
"report/"
+
report_name
attachment
=
"report/"
+
report_name
attachments
.
append
(
attachment
)
attachments
.
append
(
attachment
)
send_email
.
send_email
(
subject
,
"详情请下载查看附件"
,
attachments
=
attachments
)
send_email
.
send_email
(
subject
,
"详情请下载查看附件"
,
attachments
=
attachments
)
except
Exception
as
e
:
print
(
"邮件发送失败"
,
e
)
if
__name__
==
"__main__"
:
common
.
update_address
(
sys
.
argv
)
gd
=
getdata
.
GetData
()
phone
=
common
.
readconf
(
"user"
,
"phone"
)
password
=
common
.
readconf
(
"user"
,
"password"
)
# gd.set_token(phone, password)
gd
.
set_wan_neng_password
(
phone
,
password
)
run
()
if
__name__
==
"__main__"
:
main
=
Main
()
# 测试用例路径
case_suites
=
common
.
get_case_suites
(
"test"
)
items
=
case_suites
.
items
()
for
name
,
suite_path
in
items
:
main
.
run
(
name
,
suite_path
)
Interface_Atuo_test/jiyunying/teach_manage/debugtalk.py
View file @
7bad714a
# coding=utf-8
# coding=utf-8
import
time
import
time
from
jiyunying
import
common
from
jiyunying
import
common
import
json
import
random
,
json
,
os
import
os
def
sleep
(
n_secs
):
def
sleep
(
n_secs
):
...
@@ -13,6 +12,10 @@ def get_host() -> str:
...
@@ -13,6 +12,10 @@ def get_host() -> str:
return
common
.
set_host
()
return
common
.
set_host
()
def
get_wan_neng_password
():
return
common
.
readconf
(
"password"
,
"wan_neng_password"
)
def
get_token
():
def
get_token
():
return
common
.
readconf
(
"token"
,
"token"
)
return
common
.
readconf
(
"token"
,
"token"
)
...
@@ -24,7 +27,7 @@ variables = {
...
@@ -24,7 +27,7 @@ variables = {
def
get_course_data
():
def
get_course_data
():
course_name1
=
common
.
get_time_name
()[
1
]
course_name1
=
common
.
get_time_name
()[
1
]
print
(
os
.
getcwd
())
#
print(os.getcwd())
with
open
(
"teach_manage/data/course_data.json"
,
encoding
=
"utf-8"
)
as
fp
:
with
open
(
"teach_manage/data/course_data.json"
,
encoding
=
"utf-8"
)
as
fp
:
course_data
=
json
.
load
(
fp
)
course_data
=
json
.
load
(
fp
)
course_name2
=
course_data
[
0
][
"courseName"
]
course_name2
=
course_data
[
0
][
"courseName"
]
...
@@ -41,3 +44,32 @@ def get_course_name():
...
@@ -41,3 +44,32 @@ def get_course_name():
def
get_classNo
():
def
get_classNo
():
return
common
.
get_time_name
()[
1
]
+
"班"
return
common
.
get_time_name
()[
1
]
+
"班"
def
get_student_data
(
attendSchool
,
entrancePaper
=
None
,
introducer
=
None
,
introducerId
=
None
):
num_name
=
random
.
randint
(
0
,
10000
)
student_name
=
"自动"
+
str
(
num_name
)
with
open
(
"reception/data/student_data.json"
,
encoding
=
"utf-8"
)
as
fp
:
student_data
=
json
.
load
(
fp
)
student_data
[
"studentName"
]
=
student_name
student_data
[
"introducer"
]
=
introducer
student_data
[
"introducerId"
]
=
introducerId
student_data
[
"attendSchool"
]
=
attendSchool
student_data
[
"entrancePaper"
]
=
entrancePaper
return
student_data
def
is_skip
():
flag
=
None
host
=
common
.
readconf
(
"host"
,
"host"
)
if
host
==
"geek.jkwljy.com"
:
flag
=
True
else
:
flag
=
False
return
flag
def
get_phone
():
with
open
(
"reception/data/student_data.json"
,
encoding
=
"utf-8"
)
as
fp
:
student_data
=
json
.
load
(
fp
)
phone
=
student_data
[
"studentPrimPhoneNo"
]
return
phone
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