Thursday, June 14, 2012

Store the test results stepwise in excel file.

Whenever do you want to store each step results in excel file or datatable sheet follow below steps.
1. Add sheet in the datatable with required columns , here I am using “Result” as Sheet name and column names are ActionName, StepName, StepDescription, StepResult. For this created function.
2. Created one more function for test step results storage and reporter event results. Call this function wherever do you want to store step results in excel file or datatable.
3. At the end of the test add the datatable.Export “ file path” Statement.

'Call the Function for Addsheet in the data table
Fnaddsheet

' call the function for step result store in the data table sheet
' Enter Event Status in Digits (0-Pass , 1- Fail, 2- Done, 3- Warning
fnReproter 0,"step first","Passed","passed details"
fnReproter 1,"step first","Passed","passed details"
fnReproter 2,"step first","Passed","passed details"
fnReproter 3,"step first","Passed","passed details"


'Column names in the Result sheet ActionName, StepName, StepDescription, StepResult
Function fnAddSheet
Datatable.AddSheet "Result"
Datatable.GetSheet("Result").AddParameter "ActionName",""
Datatable.GetSheet("Result").AddParameter "StepName",""
Datatable.GetSheet("Result").AddParameter "StepDescription",""
Datatable.GetSheet("Result").AddParameter "StepResult",""
' Do you want to import your own sheet then use below statement
' Datatable.ImportSheet "C:\Result.xls",1,"Result"
End Function

Function fnReproter(strEventStatus,StepName,StepResult,StepDetails)

Reporter.ReportEvent strEventStatus, StepName & " :- " & StepResult, StepDetails
' ActionName, StepName, StepDescription, StepResult
intRowCnt=Datatable.GetSheet("Result").GetRowCount
Reporter.ReportEvent micDone,"Result sheet row count",introwcnt
Datatable.GetSheet("Result").SetCurrentRow (intRowcnt+1)
Datatable.Value("ActionName","Result")=Environment.Value("ActionName")
Datatable.Value("StepName","Result")= StepName
Datatable.Value("StepDescription","Result")=StepDetails
Datatable.Value("StepResult","Result")= StepResult

End Function

.

No comments:

Post a Comment