cancel
Showing results for 
Search instead for 
Did you mean: 

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
Community Manager

Re: onTimeout breaks onLogError activities

Community, what can we suggest?

@tristaanogre@Marsha_R@RUDOLF_BOTHMA ?

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

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
tristaanogre
Community Hero

Re: onTimeout breaks onLogError activities

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
Marsha_R
Community Hero

Re: onTimeout breaks onLogError activities

I agree with @tristaanogre 

 

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

 

 

RUDOLF_BOTHMA
Community Hero

Re: onTimeout breaks onLogError activities

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


-------------------------------------------------
Standard syntax disclaimers apply
Regards,
kakabubu
Contributor

Re: onTimeout breaks onLogError activities

@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.

kakabubu
Contributor

Re: onTimeout breaks onLogError activities

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

New Here?
Join us and watch the welcome video:
Announcements