Forum Discussion

dhundley's avatar
dhundley
Regular Contributor
2 months ago

Log.SaveResultAs is triggering OnStopTestCase Event Handler

I have an OnStopTestCase event handler in my project. it gets triggered, of course, by the end of a test case. inside this event handler, i have just placed a Log.SaveResultsAs statement and it is triggering another OnStopTestCase event recursively. i am using version 15.61.1.7 x64. anyone know why this is happening or what i might be doing wrong

2 Replies

  • dhundley's avatar
    dhundley
    Regular Contributor

    i was able to work around this issue by

    1. creating a project level boolean variable
    2. setting the variable value to true in the OnStartTestCase event handler
    3. using If logic to check the value of the variable just inside the OnStopTestCase event handler
    4. setting the variable value to false on the first line inside the If logic
    5. performing the Log.SaveResultsAs logic at the very end of the If logic

    The Log.SaveResultsAs is still triggering the OnStopTestCase event handler as soon as it is encountered but my boolean variable will prevent the second (and and all subsequent recursive) calls to all the code inside the event handler because it has been set to false when the second call is made. This still seems like a bug to me. 

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    The method Log.SaveResultsAs has a parameter called LogScope. If LogScope is set to 0, it causes a recursive call, but if you change it to either 1 (Export the project log) or 2 (Export the log of the current test item), then it should work.