-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_tests.py
35 lines (27 loc) · 1.27 KB
/
run_tests.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
import unittest
import xmlrunner
import os
import argparse
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser = argparse.ArgumentParser(description="run tests")
parser.add_argument("--unit",action="store_true",help="run unit tests")
parser.add_argument("--integration",action="store_true",help="run integration tests")
parser.add_argument("--output",choices=("xml","text"),default="xml",help="test result format, default: xml.")
parser.add_argument("--dist",choices=("arch","ubuntu"),default="ubuntu",help="linux distribution where tests are run")
args = parser.parse_args()
if not (args.integration or args.unit):
parser.error("please select test types")
suite_obj = unittest.TestSuite()
if args.integration:
s = unittest.defaultTestLoader.discover("test",pattern="test_int*.py")
suite_obj.addTest(s)
if args.unit:
s = unittest.defaultTestLoader.discover("test",pattern="test_unit*.py")
suite_obj.addTest(s)
os.environ["TEST_DISTRIBUTION"] = args.dist
runner_obj = xmlrunner.XMLTestRunner(output='test-reports')
if args.output == "text":
runner_obj = unittest.TextTestRunner()
print("Running {} tests".format(suite_obj.countTestCases()))
runner_obj.run(suite_obj)