Add simplified summary files
- one for the wiki and one as plain text
diff --git a/TestON/core/Thread.py b/TestON/core/Thread.py
index da30339..fcc06b5 100644
--- a/TestON/core/Thread.py
+++ b/TestON/core/Thread.py
@@ -18,6 +18,8 @@
if self.target is not None:
self.result = self.target( *self.args, **self.kwargs )
except Exception as e:
- print "Thread-" + str( self.threadID ) + " '" + self.name + "'"\
- ":something went wrong with " + self.target + " method"
+ print "ThreadID:" + str( self.threadID ) + ", Name:" +\
+ self.name + "- something went wrong with " +\
+ str( self.target.im_class ) + "." +\
+ str( self.target.im_func ) + " method: "
print e
diff --git a/TestON/core/logger.py b/TestON/core/logger.py
index a2c5aa7..e77d440 100644
--- a/TestON/core/logger.py
+++ b/TestON/core/logger.py
@@ -88,10 +88,16 @@
main.reportFile.write(logmsg)
main.reportFile.close()
+ #Sumamry file header
+ currentTime = str( main.STARTTIME.strftime("%d %b %Y %H:%M:%S") )
+ main.summaryFile = open( main.SummaryFileName, "w+" )
+ main.summaryFile.write( main.TEST + " at " + currentTime + "\n" )
+ main.summaryFile.close()
+
#wiki file header
currentTime = str( main.STARTTIME.strftime("%d %b %Y %H:%M:%S") )
main.wikiFile = open( main.WikiFileName, "w+" )
- main.wikiFile.write( main.TEST + " at " + currentTime + "\n" )
+ main.wikiFile.write( main.TEST + " at " + currentTime + "<p></p>\n" )
main.wikiFile.close()
def initlog(self,main):
@@ -111,7 +117,8 @@
main.LogFileName = main.logdir + "/" + main.TEST + "_" +str(currentTime) + ".log"
main.ReportFileName = main.logdir + "/" + main.TEST + "_" + str(currentTime) + ".rpt"
- main.WikiFileName = main.logdir + "/" + main.TEST + ".txt"
+ main.WikiFileName = main.logdir + "/" + main.TEST + "Wiki.txt"
+ main.SummaryFileName = main.logdir + "/" + main.TEST + "Summary.txt"
main.JenkinsCSV = main.logdir + "/" + main.TEST + ".csv"
#### Add log-level - Report
@@ -135,6 +142,17 @@
main.log.report = report
+ def summary( msg ):
+ '''
+ Will append the message to the txt file for the summary.
+ '''
+ main.log._log(6,msg,"OpenFlowAutoMattion","OFAutoMation")
+ main.summaryFile = open(main.SummaryFileName,"a+")
+ main.summaryFile.write(msg+"\n")
+ main.summaryFile.close()
+
+ main.log.summary = summary
+
def wiki( msg ):
'''
Will append the message to the txt file for the wiki.
@@ -280,20 +298,27 @@
Update the case result based on the steps execution and asserting each step in the test-case
'''
case = str(main.CurrentTestCaseNumber)
+ currentResult = main.testCaseResult.get(case, 2)
- if main.testCaseResult[case] == 2:
+ if currentResult == 2:
main.TOTAL_TC_RUN = main.TOTAL_TC_RUN + 1
main.TOTAL_TC_NORESULT = main.TOTAL_TC_NORESULT + 1
main.log.exact("\n "+"*" * 29+"\n" + "\n Result: No Assertion Called \n"+"*" * 29+"\n")
- main.log.wiki("Case "+case+": "+main.CurrentTestCase+" - No Result")
- elif main.testCaseResult[case] == 1:
+ line = "Case "+case+": "+main.CurrentTestCase+" - No Result"
+ elif currentResult == 1:
main.TOTAL_TC_RUN = main.TOTAL_TC_RUN + 1
main.TOTAL_TC_PASS = main.TOTAL_TC_PASS + 1
main.log.exact("\n"+"*" * 29+"\n Result: Pass \n"+"*" * 29+"\n")
- main.log.wiki("Case "+case+": "+main.CurrentTestCase+" - PASSED")
- elif main.testCaseResult[case] == 0:
+ line = "Case "+case+": "+main.CurrentTestCase+" - PASS"
+ elif currentResult == 0:
main.TOTAL_TC_RUN = main.TOTAL_TC_RUN + 1
main.TOTAL_TC_FAIL = main.TOTAL_TC_FAIL + 1
main.log.exact("\n"+"*" * 29+"\n Result: Failed \n"+"*" * 29+"\n")
- main.log.wiki("Case "+case+": "+main.CurrentTestCase+" - FAILED")
+ line = "Case "+case+": "+main.CurrentTestCase+" - FAIL"
+ else:
+ main.log.error( " Unknown result of case " + case +
+ ". Result was: " + currentResult )
+ line = "Case "+case+": "+main.CurrentTestCase+" - ERROR"
+ main.log.wiki( "<h3>" + line + "</h3>" )
+ main.log.summary( line )
diff --git a/TestON/core/teston.py b/TestON/core/teston.py
index 0da4cee..667f99c 100644
--- a/TestON/core/teston.py
+++ b/TestON/core/teston.py
@@ -68,13 +68,16 @@
self.TRUE = 1
self.FALSE = 0
self.ERROR = -1
+ self.NORESULT = 2
self.FAIL = False
self.PASS = True
- self.CASERESULT = self.TRUE
+ self.CASERESULT = self.ERROR
+ self.STEPRESULT = self.NORESULT
+ self.stepResults = []
self.init_result = self.TRUE
self.testResult = "Summary"
self.stepName = ""
- self.wikiCache = ""
+ self.stepCache = ""
# make this into two lists? one for step names, one for results?
# this way, the case result could be a true AND of these results
self.EXPERIMENTAL_MODE = False
@@ -188,7 +191,7 @@
self.TOTAL_TC_PASS = 0
self.TEST_ITERATION = 0
self.stepCount = 0
- self.CASERESULT = self.TRUE
+ self.CASERESULT = self.NORESULT
import testparser
testFile = self.tests_path + "/"+self.TEST + "/"+self.TEST + ".py"
@@ -208,7 +211,9 @@
def runCase(self,testCaseNumber):
self.CurrentTestCaseNumber = testCaseNumber
self.CurrentTestCase = ""
+ self.stepResults = []
self.stepName = ""
+ self.caseExplaination = ""
result = self.TRUE
self.stepCount = 0
self.EXPERIMENTAL_MODE = self.FALSE
@@ -229,44 +234,76 @@
elif result == self.TRUE:
continue
if not stopped :
+ if all( self.TRUE == i for i in self.stepResults ):
+ # ALL PASSED
+ self.CASERESULT = self.TRUE
+ elif self.FALSE in self.stepResults:
+ # AT LEAST ONE FAILED
+ self.CASERESULT = self.FALSE
+ elif self.TRUE in self.stepResults:
+ # AT LEAST ONE PASSED
+ self.CASERESULT = self.TRUE
+ else:
+ self.CASERESULT = self.NORESULT
self.testCaseResult[str(self.CurrentTestCaseNumber)] = self.CASERESULT
self.logger.updateCaseResults(self)
- self.log.wiki(self.wikiCache)
- self.wikiCache = ""
+ self.log.wiki( "<p>" + self.caseExplaination + "</p>" )
+ self.log.summary( self.caseExplaination )
+ self.log.wiki( "<ul>" )
+ for line in self.stepCache.splitlines():
+ self.log.error( repr(line) )
+ if re.search( " - PASS$", line ):
+ self.log.wiki( "<li>" + line + " <ac:emoticon ac:name=\"tick\" /></li>\n" )
+ elif re.search( " - FAIL$", line ):
+ self.log.wiki( "<li>" + line + " <ac:emoticon ac:name=\"cross\" /></li>\n" )
+ elif re.search( " - No Result$", line ):
+ self.log.wiki( "<li>" + line + " <ac:emoticon ac:name=\"warning\" /></li>\n" )
+ self.log.wiki( "</ul>" )
+ self.log.summary( self.stepCache )
+ self.stepCache = ""
return result
def runStep(self,stepList,code,testCaseNumber):
if not cli.pause:
try :
step = stepList[self.stepCount]
+ self.STEPRESULT = self.NORESULT
exec code[testCaseNumber][step] in module.__dict__
self.stepCount = self.stepCount + 1
- if step > 0: # FIXME: step 0 is from previous case - Why is it doing this?
- #FIXME are we losing results because of this?
- # Maybe we should be updating stepName sooner?
- self.wikiCache += "\t"+str(testCaseNumber)+"."+str(step)+" "+self.stepName+" - "
- if self.CASERESULT == self.TRUE:
- self.wikiCache += "PASSED\n"
- elif self.CASERESULT == self.FALSE:
- self.wikiCache += "FAILED\n"
+ if step > 0:
+ self.stepCache += "\t"+str(testCaseNumber)+"."+str(step)+" "+self.stepName+" - "
+ if self.STEPRESULT == self.TRUE:
+ self.stepCache += "PASS\n"
+ #self.stepCache += "PASS <ac:emoticon ac:name=\"tick\" /></li>\n"
+ elif self.STEPRESULT == self.FALSE:
+ self.stepCache += "FAIL\n"
+ #self.stepCache += "FAIL <ac:emoticon ac:name=\"cross\" /></li>\n"
else:
- self.wikiCache += "No Result\n"
- '''
- else: # FIXME : DEBUG
- self.wikiCache += "DEBUG\t"+str(testCaseNumber)+"."+str(step)+" "+self.stepName+" - "
- if self.CASERESULT == self.TRUE:
- self.wikiCache += "PASSED\n"
- elif self.CASERESULT == self.FALSE:
- self.wikiCache += "FAILED\n"
- else:
- self.wikiCache += "No Result\n"
- '''
+ self.stepCache += "No Result\n"
+ #self.stepCache += "No Result <ac:emoticon ac:name=\"warning\" /></li>\n"
+ self.stepResults.append(self.STEPRESULT)
except TypeError,e:
- print "Exception in the following section of code: Test Step " +\
- str(testCaseNumber) + "." + str(step) + " ):"
+ print "\nException in the following section of code: " +\
+ str(testCaseNumber) + "." + str(step) + ": " +\
+ self.stepName
#print code[testCaseNumber][step]
self.stepCount = self.stepCount + 1
self.log.exception(e)
+ self.logger.updateCaseResults(self)
+ #WIKI results
+ self.log.wiki( "<ul>" )
+ for line in self.stepCachesplitlines():
+ self.log.error( repr(line) )
+ if re.search( " - PASS$", line ):
+ self.log.wiki( "<li>" + line + " <ac:emoticon ac:name=\"tick\" /></li>\n" )
+ elif re.search( " - FAIL$", line ):
+ self.log.wiki( "<li>" + line + " <ac:emoticon ac:name=\"cross\" /></li>\n" )
+ elif re.search( " - No Result$", line ):
+ self.log.wiki( "<li>" + line + " <ac:emoticon ac:name=\"warning\" /></li>\n" )
+ self.log.wiki( "</ul>" )
+ #summary results
+ self.log.summary( self.stepCache )
+ self.stepCache = ""
self.cleanup()
self.exit()
return main.TRUE
diff --git a/TestON/core/utilities.py b/TestON/core/utilities.py
index 671dba5..dda43bf 100644
--- a/TestON/core/utilities.py
+++ b/TestON/core/utilities.py
@@ -68,28 +68,22 @@
operators = matchVar.group(2)
elif matchVar.group(1) == "_" and matchVar.group(2):
operators = matchVar.group(2)
-
except AttributeError:
if matchVar==None and nameVar:
operators ='equals'
-
- result = self._assert(NOT=notVar,operator=operators,**kwargs)
+ result = self._assert(NOT=notVar,operator=operators,**kwargs)
if result == main.TRUE:
main.log.info("Assertion Passed")
- main.CASERESULT = main.TRUE
+ main.STEPRESULT = main.TRUE
elif result == main.FALSE:
main.log.warn("Assertion Failed")
- main.CASERESULT = main.FALSE
-
- else :
+ main.STEPRESULT = main.FALSE
+ else:
main.log.error("There is an Error in Assertion")
- main.CASERESULT = main.ERROR
-
+ main.STEPRESULT = main.ERROR
return result
-
return assertHandling
-
-
+
def _assert (self,**assertParam):
'''
It will take the arguments :