mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
enhancement related to -x to take directory name/path to store xml reports
Conflicts: tools/marvin/marvin/TestCaseExecuteEngine.py
This commit is contained in:
parent
91b6e09e6d
commit
db5687d691
@ -27,7 +27,7 @@ def testCaseLogger(message, logger=None):
|
|||||||
logger.debug(message)
|
logger.debug(message)
|
||||||
|
|
||||||
class TestCaseExecuteEngine(object):
|
class TestCaseExecuteEngine(object):
|
||||||
def __init__(self, testclient, testcaseLogFile=None, testResultLogFile=None, format="text"):
|
def __init__(self, testclient, testcaseLogFile=None, testResultLogFile=None, format="text", xmlDir="xml-reports"):
|
||||||
"""
|
"""
|
||||||
Initialize the testcase execution engine, just the basics here
|
Initialize the testcase execution engine, just the basics here
|
||||||
@var testcaseLogFile: client log file
|
@var testcaseLogFile: client log file
|
||||||
@ -55,6 +55,10 @@ class TestCaseExecuteEngine(object):
|
|||||||
self.testResultLogFile = fp
|
self.testResultLogFile = fp
|
||||||
else:
|
else:
|
||||||
self.testResultLogFile = sys.stdout
|
self.testResultLogFile = sys.stdout
|
||||||
|
if self.format == "xml" and (xmlDir is not None):
|
||||||
|
self.xmlDir = xmlDir
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def loadTestsFromDir(self, testDirectory):
|
def loadTestsFromDir(self, testDirectory):
|
||||||
""" Load the test suites from a package with multiple test files """
|
""" Load the test suites from a package with multiple test files """
|
||||||
@ -91,4 +95,4 @@ class TestCaseExecuteEngine(object):
|
|||||||
if self.format == "text":
|
if self.format == "text":
|
||||||
unittest.TextTestRunner(stream=self.testResultLogFile, verbosity=2).run(self.suite)
|
unittest.TextTestRunner(stream=self.testResultLogFile, verbosity=2).run(self.suite)
|
||||||
elif self.format == "xml":
|
elif self.format == "xml":
|
||||||
xmlrunner.XMLTestRunner(output='xml-reports', verbose=True).run(self.suite)
|
xmlrunner.XMLTestRunner(output=self.xmlDir, verbose=True).run(self.suite)
|
||||||
|
|||||||
@ -31,7 +31,7 @@ if __name__ == "__main__":
|
|||||||
parser.add_option("-l", "--load", dest="load", action="store_true", help="only load config, do not deploy, it will only run testcase")
|
parser.add_option("-l", "--load", dest="load", action="store_true", help="only load config, do not deploy, it will only run testcase")
|
||||||
parser.add_option("-f", "--file", dest="module", help="run tests in the given file")
|
parser.add_option("-f", "--file", dest="module", help="run tests in the given file")
|
||||||
parser.add_option("-n", "--nose", dest="nose", action="store_true", help="run tests using nose")
|
parser.add_option("-n", "--nose", dest="nose", action="store_true", help="run tests using nose")
|
||||||
parser.add_option("-x", "--xml", dest="xmlrunner", action="store_true", help="use the xml runner to generate xml reports")
|
parser.add_option("-x", "--xml", dest="xmlrunner", action="store", default="./xml-reports", help="use the xml runner to generate xml reports and path to store xml files")
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
testResultLogFile = None
|
testResultLogFile = None
|
||||||
@ -48,7 +48,9 @@ if __name__ == "__main__":
|
|||||||
deploy.deploy()
|
deploy.deploy()
|
||||||
|
|
||||||
format = "text"
|
format = "text"
|
||||||
if options.xmlrunner:
|
xmlDir = "xml-reports"
|
||||||
|
if options.xmlrunner is not None:
|
||||||
|
xmlDir = options.xmlrunner
|
||||||
format = "xml"
|
format = "xml"
|
||||||
|
|
||||||
if options.testCaseFolder is None:
|
if options.testCaseFolder is None:
|
||||||
@ -60,7 +62,7 @@ if __name__ == "__main__":
|
|||||||
engine = NoseTestExecuteEngine.NoseTestExecuteEngine(deploy.testClient, testCaseLogFile, testResultLogFile, format)
|
engine = NoseTestExecuteEngine.NoseTestExecuteEngine(deploy.testClient, testCaseLogFile, testResultLogFile, format)
|
||||||
engine.runTestsFromFile(options.module)
|
engine.runTestsFromFile(options.module)
|
||||||
else:
|
else:
|
||||||
engine = TestCaseExecuteEngine.TestCaseExecuteEngine(deploy.testClient, testCaseLogFile, testResultLogFile, format)
|
engine = TestCaseExecuteEngine.TestCaseExecuteEngine(deploy.testClient, testCaseLogFile, testResultLogFile, format, xmlDir)
|
||||||
engine.loadTestsFromFile(options.module)
|
engine.loadTestsFromFile(options.module)
|
||||||
engine.run()
|
engine.run()
|
||||||
else:
|
else:
|
||||||
@ -68,6 +70,6 @@ if __name__ == "__main__":
|
|||||||
engine = NoseTestExecuteEngine.NoseTestExecuteEngine(deploy.testClient, clientLog=testCaseLogFile, resultLog=testResultLogFile, workingdir=options.testCaseFolder, format=format)
|
engine = NoseTestExecuteEngine.NoseTestExecuteEngine(deploy.testClient, clientLog=testCaseLogFile, resultLog=testResultLogFile, workingdir=options.testCaseFolder, format=format)
|
||||||
engine.runTests()
|
engine.runTests()
|
||||||
else:
|
else:
|
||||||
engine = TestCaseExecuteEngine.TestCaseExecuteEngine(deploy.testClient, testCaseLogFile, testResultLogFile, format)
|
engine = TestCaseExecuteEngine.TestCaseExecuteEngine(deploy.testClient, testCaseLogFile, testResultLogFile, format, xmlDir)
|
||||||
engine.loadTestsFromDir(options.testCaseFolder)
|
engine.loadTestsFromDir(options.testCaseFolder)
|
||||||
engine.run()
|
engine.run()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user