Forum Discussion
I think a solution like this, i write in a XML the test and the within a for loop i run all the tests .
Now i have a new problem :
This is my code :
def RunFailedTests():
Log.message("CreateLogFolderOnServer")
CreateLogFolderOnServer.CreateLogFolderOnServer()
Log.message("CleanLocalTestData")
ClearLocalTestData.CleanLocalTestData()
XmlFile = BuiltIn.ParamStr(6)
Log.Message("Tests failed : " + XmlFile)
if os.path.exists(XmlFile):
Log.message("Xml file exists")
else:
Log.message("Xml file doesn't exists")
return
Test_List = ParseXMLFile(XmlFile)
#CicloCheFaEseguireTuttiITestFalliti
for test in Test_List:
try:
keywordTest.test.run()
except:
log.message(Test error)
ExportLog.ExportLog()
def ParseXMLFile(XmlFile):
Test_List = []
root = ET.parse(XmlFile).getroot()
for test in root.findall('Tests/Test'):
#obtain ProjectTestItem
TestName = test.get('ProjectTestItem')
#add the test to the list
Test_List.append(TestName)
return Test_List
To run a keywordTest I should use this call : KeywordTest.TestName.Run() , the testname is contained in a variable how can i "take"the testname contained in the variable?
You're writing in Python...so I'm not sure a lot about it.
In JavaScript, JScript, or other C-based scripting languages in TestComplete, you can do the following
KeywordTests['Test1'].Run()
So, you could replace the KeywordTest name with the identifier you pull out of your XML. I don't believe that is available in Python.
So, instead, you might need to do something like this
testToRun = eval('KeywordTest.' + testName)
testToRun.Run()
- egiacomi5 years agoContributor
I solved this problem in this way .
for test in Test_List:
try:
strFunctionCall = aqString.Format("KeywordTests.%s.Run()",test)
eval(strFunctionCall)
Log.Message("Test : " + test + "has positive result")
except:
Log.Message("Test : " + test + "has negative result")if a test failed the script doesn't go to the next iteration .. at the moment i haven't a solution, do you have any ideas?
- tristaanogre5 years agoEsteemed Contributor
You're throwing an exception which probably throws an error into the log. You probably have "stop on error" turned on which is halting the project upon logging an error.
- egiacomi5 years agoContributor
Yes i have "StopOnError" option set TRUE , there is a way to disable the option only for this script ? I'm forced to set this option TRUE, do you know any workaround to this problem?
My target is skip to the next iteration in the cycle if a test successed also if a test failed
Related Content
- 5 years agodjvakarjoshi1
- 9 months agom0nkeyb0b
- 8 years agojscorzelli
Recent Discussions
- 4 hours agoSvetaG