Forum Discussion

agiletstware's avatar
agiletstware
Occasional Contributor
12 years ago

print test case name and status

Hello,

I need to print my test case name and its status (pass, fail, etc) to the log when a test case finishes.



I tried a simple onstepTest and onStartTest event, but seems like this is not supported?



Sub GeneralEvents_OnStopTest(Sender)

log.Message(Project.TestItems.Current.Name)

End Sub



Sub GeneralEvents_OnStartTest(Sender)

log.Message(Project.TestItems.Current.Name)

End Sub





I get an VBScript runtime error.



How can I print the testcase name? This should be fairly easy I hope
  • Hi,



    How are you running the tests?



    I have something similar where I use Project.TestItems.Current.Name.



    If I run the test from the individual test editor and I do not run the test from the Project Folder I get a run time error. 



    You have to add the tests to the project editor (Test Item panel) and run them from there. 


    http://support.smartbear.com/viewarticle/29618/
  • Hi,



    How are you running the tests?



    I have something similar where I use Project.TestItems.Current.Name.



    If I run the test from the individual test editor and I do not run the test from the Project Folder I get a run time error. 



    You have to add the tests to the project editor (Test Item panel) and run them from there. 


    http://support.smartbear.com/viewarticle/29618/
  • agiletstware's avatar
    agiletstware
    Occasional Contributor
    so this helps a little. Was not aware that you need to add the test to the project editor first.

    I can see the message is noe being logged. However, it does not seem to log the test case name.



    I have a Keyword Test called 'Test1'



    However, when I run the project with the following event



    Sub GeneralEvents_OnStopTest(Sender)

    log.Message(Project.TestItems.Current.Name)

    End Sub



    It prints out



    ProjectTestItem1



    How do I get it to print 'Test1'