-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.py
40 lines (32 loc) · 1.02 KB
/
test.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
import unittest
import argparse
from test.demo_test_case import DemoTestCase
def get_unit_test():
return unittest.TestLoader().discover('test/unit')
def get_functional_test():
return unittest.TestLoader().discover('test/functional')
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument(
'-U', '--url', help='url to test',
default='http://127.0.0.1:8080'
)
parser.add_argument(
'-u', '--unit', help='run untit test',
action='store_true'
)
parser.add_argument(
'-f', '--functional', help='run functional test',
action='store_true'
)
args = parser.parse_args()
DemoTestCase.config['demo_url'] = args.url
test_suite = unittest.TestSuite()
if args.unit:
test_suite.addTest(get_unit_test())
if args.functional:
test_suite.addTest(get_functional_test())
runner = unittest.runner.TextTestRunner(verbosity=3)
result = runner.run(test_suite)
if not result.wasSuccessful():
exit(1)