GeneralEvents_OnStopTest(Sender) - differentiate manual stop from others
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
GeneralEvents_OnStopTest(Sender) - differentiate manual stop from others
Hi,
In order to perform some actions when ending a test, I use the classic function GeneralEvents_OnStopTest(Sender) linked to the OnStopTest event.
I would like to have a different behavior when I manually stop a test (using the STOP button) than when a test closes for another reason. More particularly when a test ended, I check for remaining processes and kill them if exist, that's I would like to avoid when stopping test manually.
I didn't find a way to discriminate between the two situations.
First I was looking to check some properties of the Sender object but this one is always "undefined".
In another hand, as an error labelled "Script execution was interrupted." is added to the Log when a test is manually stopped, I've also tried to check for the "Script execution was interrupted." message in the GeneralEvents_OnLogError(Sender, LogParams) method, but this method is not called when the test is manually stopped.
Is there a reason why Sender is always undefined ?
Is there a way to find when test is stopped manually ?
Thanks for your help,
Best,
Christophe
I use TC 9.0.1069.7 (and can't upgrade for compatibility reason) and script are in C#Script.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
So I thought you could maybe evaluate the message in the log...and you can get to that by:
Project.Logs.LogItem(Project.Logs.LogItemsCount - 1)
And then by digging deep into the log like...
Project.Logs.LogItem(Project.Logs.LogItemsCount - 1).Child(0).Child(0).Data(0).Rows(0).ChildRow(0).ChildRow(0).ValueByName("Message");
BUT the problem is the log message "Script execution was interrupted." is not written until after the OnStopTest event fires.
So I think it's probably easier to figure out where your script stops "Naturally"...
and then have it call a different function to terminate the processes instead of terminating them from the OnStopTest event.
''-Praise the sun and Give Kudos.''
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As I understand it, the "Sender" is an object that is used internally by TestComplete and is not something that can be manipulated by the script code.
However, here's a suggestion. Since you are going to by stopping the test manually, the assumption is that you are monitoring it and are watching it manually. So... put a breakpoint in your OnStopTest handler code before the "cleanup" and, when you hit that breakpoint, just click the "stop" button in the IDE to stop all execution.
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
