Ask a Question

event handler for OnStopTestCase

dhundley
Regular Contributor

event handler for OnStopTestCase

i'm having a bit of trouble understanding how the OnStopTestCase event handler gets triggered. I'm attaching a few screen shots to show how i think it should work. 

 

the execution plan screenshot shows that i have several "test items" (i.e keyword tests) but only one has the checkbox checked as a "test case"

the generate events screenshot shows that i have added the handler for OnStopTestCase

the javascript function show the top few lines of the script that i wrote for the event handler. as you can see i put several log messages at the top just to see what text gets put into the log but when my run ended i saw none of these messages anywhere as shown in the successful run messages screen shot.

 

am i looking in the wrong place for the messages? the script inside the IF statement that follows the log messages did not run at the end of the test case. do i need to use the sender parameter or something? also i tried using OnStopTest but that gets invoked after the end of every "test item" listed in the execution plan even though their "test case" checkbox is unchecked. this is not a script I want to run after every keyword test finishes. only when the parent "SignInOut" is complete. any and all help/suggestions appreciated. 

 

thanks!

 

7 REPLIES 7
Marsha_R
Champion Level 3

Here's the documentation for OnStopTestCase

https://support.smartbear.com/testcomplete/docs/reference/events/onstoptestcase.html

 

If it doesn't fit where you would like it to, at the bottom of the article, you'll see a link to Handling Events

https://support.smartbear.com/testcomplete/docs/testing-with/advanced/handling-events/index.html

 

You can use that to create your own event handlers.

dhundley
Regular Contributor

i have been looking at both those articles for quite a while now and still not "getting" it. When i used testcomplete a couple of years ago (i could be wrong but) i don't remember there being an execution plan in the project with all those checkboxes. were "test cases" identified somehow differently in the past? in the article found at 

https://support.smartbear.com/testcomplete/docs/testing-with/advanced/handling-events/creating-handl...

it doesn't even show the two handlers for test cases only for tests. is that article outdated because my testcomplete lists both of them under Test Engine Events. 

The first linked article you posted says this about OnStopTestCase:

Description

Occurs when TestComplete stops running a test case:

  • When the execution of any project test item marked as a test case is stopped (regardless of whether you run individual test items or the entire project).

Well, i have marked SignInOut as a test case in my execution plan. all the test items are children of it. i would think that when the last child completes the parent testcase is complete (stops running). 

 

as for the second link in your reply aren't you still restricted to use only the event handlers that appear in the "available events" list? 

 

Examples would really be helpful here. thanks!

What version of TestComplete are you using?

dhundley
Regular Contributor

Version: 15.30.355.7 x64

I think you could use this example for what you are trying to do.  Check for the current name to be equal to that of your parent test case.

https://support.smartbear.com/testcomplete/docs/testing-with/advanced/handling-events/creating-handl...

 

Marsha_R_0-1646356223420.png

 

dhundley
Regular Contributor

yes, i saw that example but the OnStopTestCase event handler does not get triggered when the item i have marked as a test case in my execution plan (SignInOut) is complete. I have put the OnStopTest event handler back in and i am using the following IF statement in it which does work since CloseNuPoint is the last test item/keyword script inside the SignInOut test case

 

if (Project.TestItems.Current.Parent.Name == "SignInOut" && Project.TestItems.Current.Name == "CloseNuPoint" )

 

I would still prefer to figure out how to resolve the issue that would allow the OnStopTestCase event handler to get triggered since it has the whole list of StopTestCaseParams getting passed into it and OnStopTest does not. I just think there has to be something about the execution plan checkbox that isn't really causing that to be literally considered a test case. maybe a project option or something? i have no idea. 

 

Thanks. I'll utilize my work around but might refrain from clicking the accept as option button to see if anyone has any more ideas about triggering the  OnStopTestCase event handler and the execution plan test case checkbox. 

dhundley
Regular Contributor

Marsha,

 

When you say "You can use that to create your own event handlers."

 

are you suggesting that i can somehow create a javascript event handler that can be "added" to the list of existing event handlers (such as onstoptest, onstarttest, etc.) that appear under Events -> GeneralEvents and in the Available Events list of either General or Test Engine Events (as shown in the screen shot i attached named Generate Events.png)? if not, please elaborate on what you mean by creating my own event handlers and how that would work.

 

thanks!

cancel
Showing results for 
Search instead for 
Did you mean: