forked from tredston/TNTFL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_tests.py
69 lines (52 loc) · 2.03 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
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
import argparse
import os
import re
import sys
import unittest
import tntfl.test.test_achievements as test_achievements
import tntfl.test.test_game_store as test_game_store
import tntfl.test.test_ladder as test_ladder
import tntfl.test.test_pundit as test_pundit
import tntfl.test.test_scripts as test_scripts
import tntfl.test.test_deployment as test_deployment
import tntfl.test.transforms as transforms
def clearCache():
print 'Clearing cache'
cacheFile = '.cache.*'
for f in os.listdir('.'):
if re.search(cacheFile, f):
os.remove(f)
def unitTestSuite():
test_suite = unittest.TestSuite()
test_suite.addTest(unittest.findTestCases(test_achievements))
test_suite.addTest(unittest.findTestCases(test_game_store))
test_suite.addTest(unittest.findTestCases(test_ladder))
test_suite.addTest(unittest.findTestCases(test_pundit))
test_suite.addTest(unittest.findTestCases(transforms))
return test_suite
def functionalTestSuite():
test_suite = unittest.TestSuite()
test_suite.addTest(unittest.findTestCases(test_scripts))
return test_suite
def integrationTestSuite():
test_suite = unittest.TestSuite()
test_suite.addTest(unittest.findTestCases(test_deployment))
return test_suite
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('-i', '--integration', dest='runIntegration', action='store_true')
parser.set_defaults(runIntegration=False)
args = parser.parse_args()
clearCache()
runner = unittest.TextTestRunner()
print 'Running unit tests:'
result = runner.run(unitTestSuite())
if len(result.errors) == 0 and len(result.failures) == 0:
print 'Running functional tests:'
result = runner.run(functionalTestSuite())
if len(result.errors) == 0 and len(result.failures) == 0 and args.runIntegration:
print 'Running integration tests:'
result = runner.run(integrationTestSuite())
clearCache()
ok = len(result.errors) == 0 and len(result.failures) == 0
sys.exit(not ok)