forked from couchbaselabs/sync-gateway-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtap_2_junit.py
49 lines (36 loc) · 1.4 KB
/
tap_2_junit.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
import unittest
import xmlrunner
class TestSequence(unittest.TestCase):
pass
def test_generator(b):
def test(self):
self.assertTrue(b)
return test
def tap_junit_xml():
with open("results.tap", "r") as f:
lines = f.readlines()
for line in lines:
if line.startswith("not ok"):
print("TEST FAILURES!!!")
print(line)
if line.startswith("total"):
total_results = line.split()[2]
print(total_results)
total_parts = total_results.split("/")
total_tests = int(total_parts[1])
passed = int(total_parts[0])
failed = total_tests - passed
print("TOTAL: {}".format(total_tests))
print("PASSED: {}".format(passed))
print("FAILED: {}".format(failed))
for t in xrange(0, passed):
test_name = 'test_pass_%s' % t
test = test_generator(True)
setattr(TestSequence, test_name, test)
for t in range(0, failed):
test_name = 'test_failed_%s' % t
test = test_generator(False)
setattr(TestSequence, test_name, test)
unittest.main(testRunner=xmlrunner.XMLTestRunner(output='test-reports'))
if __name__ == '__main__':
tap_junit_xml()