run.py
2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Time : 2022/12/8 21:52
# @Author : Shitou
# @FileName: run.py
# @Software: PyCharm
import unittest
from unittestreport import TestRunner
from common.handle_path import TestCase_Path, Report_Path
from common.handle_config import conf
from testcase.test_01_login import TestLogin
from testcase.test_02_system_management import Test01Department, Test02Specialty, Test03Year
from testcase.test_03_teaching_affairs import Test01Teacher, Test02Class, Test03Course, Test04Student
from testcase.test_04_Internship_preparation import Test01InternshipPlan
"""
执行所有用例
"""
# # 创建测试套件
# suite = unittest.TestSuite()
# # 加载用例
# # ---创建加载器
# load = unittest.TestLoader()
# # ---用例放到加载器
# suite.addTest(load.discover(TestCase_Path))
"""
执行单独模块用例
"""
a = unittest.TestLoader().loadTestsFromTestCase(Test01InternshipPlan)
# b = unittest.TestLoader().loadTestsFromTestCase(Test03Year)
suite = unittest.TestSuite([a])
# # 运行
runner = TestRunner(suite=suite,
filename=conf.get("report", "filename"),
report_dir=Report_Path,
title=conf.get("report", "title"),
tester=conf.get("report", "tester"),
desc=conf.get("report", "desc"),
templates=conf.getint("report", "templates")
)
runner.run()
# 执行失败重新运行机制
# runner.rerun_run(count=3, interval=0.2)
"""
发送钉钉
"""
# Webhook = "https://oapi.dingtalk.com/robot/send?access_token=cb3e40995683f06c5be06074e0cf617f2ea208156e3b4bf6247b56a212b8b7c3"
# Webhook = "https://oapi.dingtalk.com/robot/send?access_token=054f620071c74d94c10ad556743aa5ff0600a2953bbce5529ca057f75ad2423e" # 优秀学乐业钉钉群
# runner.dingtalk_notice(url=Webhook,
# key="石头测试", # 传入钉钉设置的对应关键字
# atMobiles=["17301249973"], # 发送通知钉钉中要@人的手机号列表
# isatall=False, # 是否@所有人,默认为False,设为True则会@所有人
# except_info=True # 是否发送未通过用例的详细信息,默认为False
# )
"""
发送邮件
"""
# runner.send_email(host="smtp.qq.com",
# port=465,
# user="shishut@foxmail.com",
# password="uwgmbvzjfscqbeeh",
# to_addrs=["shishut@workai.com.cn"]
# # to_addrs=["shishut@workai.com.cn", "wangf@workai.com.cn"]
# )