-
Notifications
You must be signed in to change notification settings - Fork 2
/
test_runner.py
79 lines (60 loc) · 1.99 KB
/
test_runner.py
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
# -*- coding=utf-8 -*-
"""
About this module
All tests will start from this module.
Description of classes
None
Description of methods
execute_test: Execute the test cases in the test_suite.
"""
__authors__ = [
'"Hugo Ding" <dinghuicong@gmail.com>',
]
__version__ = "V0.1"
__all__ = []
# ChangeLog:
# Version Date Description Author
# ------------------------------------------------------------------------------
# V0.1 2014-12-21 First version Hugo
# ------------------------------------------------------------------------------
import sys
from logging_report.HTMLTestRunner import HTMLTestRunner
from utility.config_parser import get_config
from utility.test_suite import get_test_suite, get_testcase
from logging_report.logging_ import print_log
from system_opration.command_line import get_opt
from system_opration.file_system import get_test_report_path
sys.dont_write_bytecode = True
def execute_test(test_suite):
"""
:summary: Execute test cases.
:param test_suite: Test suite.
"""
exec_type = get_config("run-time", "mode")
print_log("="*80, "info")
print_log(
"Execution started, execution type is %s, "
% exec_type
)
print_log("Testcase(s) to run is(are): \n%s" % str(test_suite))
result_file = get_test_report_path()
fp = open(result_file, 'wb')
runner = HTMLTestRunner(
stream=fp,
title="Automation test report",
description=(
"Automation test report\n"
"Execution type is %s" % exec_type
)
)
runner.run(test_suite)
if __name__ == "__main__":
cmd_mode = get_opt().get("mode")
mode = cmd_mode if cmd_mode else get_config("run-time", "mode")
test_cases = get_testcase(mode)
# test_cases = [
# "testcase.web.login_demo.ValidLogin",
# ]
suite = get_test_suite(test_cases)
# unittest.TextTestRunner(verbosity=2).run(suite)
execute_test(suite)