Skip to content
Snippets Groups Projects
Commit 624c655f authored by felmer's avatar felmer
Browse files

SSDM-3505: improved content of targets/test-results/TEST-integration.xml

SVN: 36278
parent 227583a1
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,7 @@ import os ...@@ -7,6 +7,7 @@ import os
import os.path import os.path
import sys import sys
import time import time
import traceback
import settings import settings
from systemtest.util import printAndFlush, renderDuration from systemtest.util import printAndFlush, renderDuration
...@@ -14,14 +15,12 @@ from systemtest.util import printAndFlush, renderDuration ...@@ -14,14 +15,12 @@ from systemtest.util import printAndFlush, renderDuration
startTime = time.time() startTime = time.time()
testCases = [] testCases = []
failedTestCases = {} failedTestCases = {}
numberOfTestCases = 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__)))):
splittedFileName = f.rsplit('.', 1) splittedFileName = f.rsplit('.', 1)
if len(splittedFileName) > 1: if len(splittedFileName) > 1:
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':
testCases.append(moduleName) testCases.append(moduleName)
try: try:
__import__(moduleName) __import__(moduleName)
...@@ -39,8 +38,11 @@ with open('targets/test-results/TEST-integration.xml', 'w') as out: ...@@ -39,8 +38,11 @@ with open('targets/test-results/TEST-integration.xml', 'w') as out:
for testCase in testCases: for testCase in testCases:
if testCase in failedTestCases: if testCase in failedTestCases:
out.write(" <testcase name='%s'>\n" % testCase) out.write(" <testcase name='%s'>\n" % testCase)
exceptionInfo = failedTestCases[testCase]
out.write(" <failure>\n") out.write(" <failure>\n")
out.write(" %s\n" % failedTestCases[testCase][1]) msgs = traceback.format_exception(exceptionInfo[0], exceptionInfo[1], exceptionInfo[2])
for msg in msgs:
out.write(" %s\n" % msg)
out.write(" </failure>\n") out.write(" </failure>\n")
out.write(" </testcase>\n") out.write(" </testcase>\n")
else: else:
...@@ -48,6 +50,7 @@ with open('targets/test-results/TEST-integration.xml', 'w') as out: ...@@ -48,6 +50,7 @@ with open('targets/test-results/TEST-integration.xml', 'w') as out:
out.write("</testsuite>\n") out.write("</testsuite>\n")
printAndFlush('=====================================') printAndFlush('=====================================')
printAndFlush("%d test cases executed in %s" % (len(testCases), renderedDuration)) printAndFlush("%d test cases executed in %s" % (len(testCases), renderedDuration))
numberOfFailedTestCases = len(failedTestCases)
if numberOfFailedTestCases == 0: if numberOfFailedTestCases == 0:
printAndFlush("no test case failed") printAndFlush("no test case failed")
exit(0) exit(0)
......
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