Wednesday, December 28, 2011

Custom Reporter

'Custom reporter sending data to simple txt file
'Usage: CustomReporter "strStatus", "strStepName", "strMessage"
Public Function CustomReporter(strStatus, strStepName, strMessage)
'Override it with our custom class
Dim Reporter
Set Reporter = New clsReporter
Reporter.ReportEvent strStatus, strStepName, strMessage
End Function 'CustomReporter

Define a funnel function to be called from the test actions
Public Function GetReporter
Set GetReporter = Reporter
End Function

'Class definition
'In the example, our class just reporter to a text file
Class clsReporter
Dim oFileReporter

Public Sub ReportEvent(iStatus, sStepName, sDetails)
oFileReporter.AppendAllText "c:\log.txt", now & " ===> " & iStatus & " - " & sStepName & " - " & sDetails & vbcrlf
End Sub

Private Sub Class_Initialize
Set oFIleReporter = DotNetFactory("System.IO.File")
End Sub
End Class

No comments:

Post a Comment