Skip to content
Snippets Groups Projects
Commit 227583a1 authored by felmer's avatar felmer
Browse files

SSDM-3505: creating targets/test-results/TEST-integration.xml

SVN: 36277
parent c3e6500c
No related branches found
No related tags found
No related merge requests found
...@@ -11,7 +11,9 @@ import time ...@@ -11,7 +11,9 @@ import time
import settings import settings
from systemtest.util import printAndFlush, renderDuration from systemtest.util import printAndFlush, renderDuration
startTime = time.time() startTime = time.time()
testCases = []
failedTestCases = {}
numberOfTestCases = 0 numberOfTestCases = 0
numberOfFailedTestCases = 0 numberOfFailedTestCases = 0
for f in sorted(os.listdir(os.path.dirname(os.path.abspath(__file__)))): for f in sorted(os.listdir(os.path.dirname(os.path.abspath(__file__)))):
...@@ -20,18 +22,37 @@ for f in sorted(os.listdir(os.path.dirname(os.path.abspath(__file__)))): ...@@ -20,18 +22,37 @@ for f in sorted(os.listdir(os.path.dirname(os.path.abspath(__file__)))):
moduleName = splittedFileName[0] moduleName = splittedFileName[0]
fileType = splittedFileName[1] fileType = splittedFileName[1]
if moduleName.startswith('test_') and fileType == 'py': if moduleName.startswith('test_') and fileType == 'py':
numberOfTestCases += 1 testCases.append(moduleName)
try: try:
__import__(moduleName) __import__(moduleName)
except: except:
numberOfFailedTestCases += 1 failedTestCases[moduleName] = sys.exc_info()
renderedStartTime = time.strftime('%Y-%m-%dT%H:%M:%S', time.localtime(startTime))
renderedDuration = renderDuration(time.time() - startTime)
testResultsFolder = 'targets/test-results'
if not os.path.exists(testResultsFolder):
os.mkdir(testResultsFolder)
with open('targets/test-results/TEST-integration.xml', 'w') as out:
out.write('<?xml version="1.1" encoding="UTF-8"?>\n')
out.write("<testsuite name='integration' tests='%s' failures='%s' errors='0' timestamp='%s' time='%s'>\n"
% (len(testCases), len(failedTestCases), renderedStartTime, renderedDuration))
for testCase in testCases:
if testCase in failedTestCases:
out.write(" <testcase name='%s'>\n" % testCase)
out.write(" <failure>\n")
out.write(" %s\n" % failedTestCases[testCase][1])
out.write(" </failure>\n")
out.write(" </testcase>\n")
else:
out.write(" <testcase name='%s'/>\n" % testCase)
out.write("</testsuite>\n")
printAndFlush('=====================================') printAndFlush('=====================================')
printAndFlush("%d test cases executed in %s" % (numberOfTestCases, renderDuration(time.time() - startTime))) printAndFlush("%d test cases executed in %s" % (len(testCases), renderedDuration))
if numberOfFailedTestCases == 0: if numberOfFailedTestCases == 0:
printAndFlush("no test case failed") printAndFlush("no test case failed")
exit(0) exit(0)
if numberOfFailedTestCases == 1: if numberOfFailedTestCases == 1:
printAndFlush("1 test case failed") printAndFlush("1 test case failed")
else: else:
printAndFlush("%d test cases failed" % numberOfFailedTestCases) printAndFlush("%d test cases failed" % len(failedTestCases))
exit(1) exit(1)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment