Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
泰斯特Test
Taisite-Platform
提交
ab84fb72
T
Taisite-Platform
项目概览
泰斯特Test
/
Taisite-Platform
10 个月 前同步成功
通知
121
Star
28
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Taisite-Platform
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
ab84fb72
编写于
9月 26, 2020
作者:
泰斯特Test
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[refact]兼容定时任务下测试总耗时计算
上级
65149b56
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
15 addition
and
3 deletion
+15
-3
backend/utils/cron/interfaceTestCron.py
backend/utils/cron/interfaceTestCron.py
+15
-3
未找到文件。
backend/utils/cron/interfaceTestCron.py
浏览文件 @
ab84fb72
...
...
@@ -4,11 +4,12 @@ from models.testingCase import TestingCase
from
models.mailSender
import
MailSender
from
testframe.interfaceTest.tester
import
tester
from
models.testReport
import
TestReport
from
models.project
import
Project
import
pymongo
from
bson
import
ObjectId
import
datetime
import
requests
import
time
class
Cron
:
def
__init__
(
self
,
test_case_suite_id_list
,
test_domain
,
trigger_type
,
is_execute_forbiddened_case
=
False
,
...
...
@@ -101,7 +102,7 @@ class Cron:
def
get_id
(
self
):
return
self
.
_id
def
generate_test_report
(
self
,
project_id
,
cron_id
,
test_result_list
):
def
generate_test_report
(
self
,
project_id
,
cron_id
,
test_result_list
,
total_test_spending_time
,
project_name
):
test_count
=
len
(
test_result_list
)
passed_count
=
len
(
...
...
@@ -117,6 +118,7 @@ class Cron:
raw_data
=
{
"projectId"
:
ObjectId
(
project_id
),
"projectName"
:
project_name
,
"testCount"
:
test_count
,
"passCount"
:
passed_count
,
"failedCount"
:
failed_count
,
...
...
@@ -124,6 +126,8 @@ class Cron:
"comeFrom"
:
execute_from
,
"executorNickName"
:
"定时机器人"
,
"cronId"
:
cron_id
,
"totalTestSpendingTimeInSec"
:
total_test_spending_time
,
"testDomain"
:
self
.
test_domain
,
"testDetail"
:
test_result_list
,
"createAt"
:
datetime
.
datetime
.
utcnow
()
# 存入库时什么datetime都当utc使
}
...
...
@@ -171,19 +175,27 @@ class Cron:
cron_test_cases_list
=
self
.
get_cron_test_cases_list
()
if
len
(
cron_test_cases_list
)
>
0
:
project_id
=
cron_test_cases_list
[
0
][
"projectId"
]
project_name
=
Project
.
find_one
({
'_id'
:
ObjectId
(
project_id
)})[
'name'
]
else
:
raise
TypeError
(
'定时任务执行中未找到任何可执行用例!'
)
tester_for_cron
=
tester
(
test_case_list
=
cron_test_cases_list
,
domain
=
self
.
test_domain
)
total_test_start_time
=
time
.
time
()
test_result_list
=
tester_for_cron
.
execute_all_test_for_cron_and_single_test
()
total_test_end_time
=
time
.
time
()
total_test_spending_time
=
round
(
total_test_end_time
-
total_test_start_time
,
3
)
for
index
,
test_result
in
enumerate
(
test_result_list
):
test_result
=
common
.
format_response_in_dic
(
test_result
)
test_result_list
[
index
]
=
test_result
if
len
(
test_result_list
)
>
0
:
self
.
generate_test_report
(
project_id
,
self
.
get_id
(),
test_result_list
)
self
.
generate_test_report
(
project_id
,
self
.
get_id
(),
test_result_list
,
total_test_spending_time
,
project_name
)
is_send_mail
=
self
.
failed_count
>
0
and
isinstance
(
self
.
alarm_mail_list
,
list
)
\
and
len
(
self
.
alarm_mail_list
)
>
0
is_send_ding_ding
=
self
.
ding_ding_access_token
if
hasattr
(
self
,
'ding_ding_access_token'
)
else
False
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录