Forum Discussion

agiletstware's avatar
agiletstware
Occasional Contributor
12 years ago

How to print testcase warning/failure message

Hello,

I need to log the test case name, status, and error/warning message (in case of error or warning) to a flat file using a custom .net dll. I have the following code for printing the testcase name and status. Can someone help with how to print out the error/warning message ?




Sub GeneralEvents_OnStopTest(Sender)

       Dim tstatus

       Select Case(  Project.Logs.LogItem(Project.Logs.LogItemsCount - 1).Status )

       Case 0

                tstatus = "PASSED"

       Case 1

                tstatus = "WARNING"  

       Case 2

                tstatus = "FAILED"    

       End Select

       

      dotNET.WriteToFile(Project.TestItems.Current.Name, tstatus , "need to print error/warning message here")






1 Reply

  • Hi,



    Can you clarify your request - what "error/warning message" do you mean? At the time OnStopTest executes, nothing is being posted to the log. And there can be multiple errors or warnings posted during the test execution.



    If you just want to have the last error or warning in OnStopTest, handle the OnLogError (and/or OnLogWarning) event, save the message text to a project variable and then use this variable in the OnStopTest handler.