Unverified Commit 2ae36ba0 authored by boklm's avatar boklm
Browse files

run_test: save result in a json file if SELENIUM_TEST_RESULT_FILE is set

parent dab869b0
#!/usr/bin/python
import unittest, time, re
import sys
import json
import os
def save_result(testres):
if not os.environ.get('SELENIUM_TEST_RESULT_FILE'):
return
res = {}
res['success'] = testres.wasSuccessful()
res['total_tests'] = testres.testsRun
res['failed'] = []
failures = testres.failures + testres.errors
for f in failures:
r = {}
r['id'] = f[0].id()
r['error'] = f[1]
res['failed'].append(r)
output = open(os.environ.get('SELENIUM_TEST_RESULT_FILE'), 'w')
output.write(json.dumps(res))
output.close()
if len(sys.argv) != 2:
sys.exit('Usage: run_test <test_name>')
......@@ -8,3 +28,4 @@ if len(sys.argv) != 2:
t = __import__('test_%s' % sys.argv[1])
suite = unittest.TestLoader().loadTestsFromTestCase(t.Test)
res = unittest.TextTestRunner(verbosity=2).run(suite)
save_result(res)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment