Ask a Question

onTimeout breaks onLogError activities

kakabubu
Contributor

onTimeout breaks onLogError activities

I have onTimeout and onLogError even handlers overwritten

Spoiler

here is my implementation of the event handlers

const isTest = () => !!Project.TestItems.Current;

function GeneralEvents_OnLogError(Sender, LogParams) { if (!isTest() || testIsStoping || LogParams.Priority === pmLowest) return true; testIsStoping = true; Log.Error(LogParams.MessageText, LogParams.AdditionalText, pmLowest); logs.indentLog('Stop test on Error and reset test environment.'); afterFailedTest(); logs.outdentLog(); logs.post(ProjectSuite.Variables.config.postLogsOnError); LogParams.Locked = true; return Runner.Stop(true); } function GeneralEvents_OnTimeout(Sender, LogParams) { return testIsStoping ? true : GeneralEvents_OnLogError(...arguments); }

function afterFailedTest() {
//...
//some actions with application are perfomed here
//...
}

Sometimes the timeout expires while onLogError event handler did not finish. In that case, the following tests are broken because onTimeout event terminates tested application while some important actions are running.

From the articles I've found, (Timeout Property OnTimeout Event Stopping Tests on Timeout) I've picked the following info:

  • The app is terminated before the event handler called
  • Project.TestItems.Current.TimeOut is readOnly

Please help me to understand what is the right way to handle this case.

 

@cunderw, i believe you could have similar problems.
6 REPLIES 6
TanyaYatskovska
SmartBear Alumni (Retired)

Community, what can we suggest?

@tristaanogre@Marsha_R@RUDOLF_BOTHMA ?

---------
Tanya Yatskovskaya
SmartBear Community and Education Manager



tristaanogre
Esteemed Contributor

I don't think, honestly, that it's a good practice to explicitly call a handler routine inside another handler.  Each handler needs to handle it's event.  


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

I agree with @tristaanogre 

 

It's caused two problems doing it this way, because now we can't tell which handler is doing what.

 

 


Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame

Might it in some way be something similar to this Previous post ?


-------------------------------------------------
Standard syntax disclaimers apply
Regards,

@tristaanogre@Marsha_R 
Ok. I can refactor my code in a way not to call the event handler from the other event handler.


But my problem is that the onTimeout event terminates the application, while onLogError event is still running the afterTestFail routine
To be exact, it terminates the application while the application database restore is performed. That causes the database to appear disabled. Which causes the following tests to fail.

I can adjust the test timeouts. But it seems to be not the best solution, in my opinion.

@RUDOLF_BOTHMA 
Thank you. I saw that discussion, but I didn`t find it useful in my case.

cancel
Showing results for 
Search instead for 
Did you mean: