forked from HugoDing/ATF
/
test_runner.py
67 lines (50 loc) · 1.59 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
# -*- 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
# ------------------------------------------------------------------------------
from unittest import TestSuite, TestLoader
from logging_report.HTMLTestRunner import HTMLTestRunner
from utility.config_parser import get_config
from logging_report.logging_ import print_log
def execute_test(test_suite):
"""
@summary: Execute test cases.
@param test_suite: Test suite.
"""
exec_type = get_config("run-time", "mode")
print_log("Testcase(s) to run is(are): %s" % test_suite)
result_file = "D:\\test_result.html"
fp = file(result_file, 'wb')
runner = HTMLTestRunner(
stream=fp,
title=u"Automation test report",
description=(
u"Automation test report\n"
u"Execution type is %s" % exec_type
)
)
runner.run(test_suite)
if __name__ == "__main__":
test_cases = [
"testcase.web.login_demo.ValidLogin"
]
suite = TestSuite()
loader = TestLoader()
tests = loader.loadTestsFromNames(test_cases)
suite.addTests(tests)
execute_test(suite)