run.py
3.2 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Time : 2022/12/8 21:52
# @Author : Shitou
# @FileName: run.py
# @Software: PyCharm
# import sys
# import os
# curPath = os.path.abspath(os.path.dirname(__file__))
# rootPath = os.path.split(curPath)[0]
# sys.path.append(rootPath)
import unittest
from common.handle_config import conf
from unittestreport import TestRunner
from tools.function import runner_test
from common.handle_path import TestCase_Path, Report_Path
# 登陆
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 Test01addInternshipPlan, Test02publishInternshipPlan, \
Test03addInternshipProject, Test04publishInternshipProject
# 学生查看实习、学生报名、
from testcase.test_05_student_practice import Test01SelectAllPractice, Test02StudentApply
# 查看报名审核、报名审核-学校端-进行审核、报名审核-hr端-待审核列表查看(实习申请列表)、 报名审核-hr端-进行审核
from testcase.test_06_internship_manage import Test01SelectApplyAuditList, Test02SchoolAudit
"""
执行所有用例
"""
# 创建测试套件
suite_all = unittest.TestSuite()
# 加载用例
# ---创建加载器
load = unittest.TestLoader()
# ---用例放到加载器
suite_all.addTest(load.discover(TestCase_Path))
"""
# 执行单独模块用例
# """
a1 = unittest.TestLoader().loadTestsFromTestCase(TestLogin)
a2 = unittest.TestLoader().loadTestsFromTestCase(Test01Department)
a3 = unittest.TestLoader().loadTestsFromTestCase(Test02Specialty)
a4 = unittest.TestLoader().loadTestsFromTestCase(Test03Year)
a5 = unittest.TestLoader().loadTestsFromTestCase(Test02Class)
a6 = unittest.TestLoader().loadTestsFromTestCase(Test04Student)
bbbbbb = unittest.TestLoader().loadTestsFromTestCase(Test02SchoolAudit)
cccc = unittest.TestLoader().loadTestsFromTestCase(Test01addInternshipPlan)
suite = unittest.TestSuite([a1, a2, a3, a4, a5, a6])
suite_a = unittest.TestSuite([cccc])
# runner_test(suite_all) # 执行
# runner_test(suite_a) # 执行
# input_case = input("请输入需要执行的用例:")
# try:
# if input_case in "全部":
# suite = suite_all
# elif input_case in "教师":
# suite = suite_teacher
# runner_test(suite) # 执行
#
# except NameError as a:
# print("输入错误")
# else:
# print("执行完毕,请确认")
# 运行文件
runner = TestRunner(suite=suite_all,
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=2, interval=0.2)