Ask a Question

Getting Name of Failed test in OnLogError Event

SOLVED
pkudrys
Occasional Contributor

Getting Name of Failed test in OnLogError Event

Hi,

 

This is a followup to the old question posted here:

https://community.smartbear.com/t5/TestComplete-Questions/Getting-Name-of-Failed-test-in-OnLogError-...

Unfortunately, none of the suggested solutions works.

 

Does anyone know, how to get the name of failed test? "Sender.Name" only returns name of EventControl module, but I need the name of keyword/script module, which is the error coming from. Thanks.

6 REPLIES 6
Marsha_R
Community Hero

See if this helps

https://support.smartbear.com/testcomplete/docs/testing-with/running/get-test-name.html


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
rraghvani
Valued Contributor

If you use Execution Plan, then it works,

rraghvani_1-1674501927206.png

 

pkudrys
Occasional Contributor

Hi folks,

 

Thank you for your suggestions. It turned out to be a problem between the chair and keyboard 🙂 aqTestCase.CurrentTestCase.Name definitely works as expected. I just forgot to enable Test case checkbox in the execution plan. In this case, CurrentTestCase.Name, logically, returns null 🙂

 

On the other hand, it would be nice to have an option to return the module name, regardless of enabled "Test case" checkbox. My modules are not always planned as test cases, but I still want to get their names from code. And this is where the CurrentTestCase.Name fails to deliver the module name.

rraghvani
Valued Contributor

Another approach is to use a global variable, set the name in each test case like so,

rraghvani_0-1674551519337.png

 

pkudrys
Occasional Contributor

Hi,

 

Thanks for the additional suggestion. This was also my idea as a last resort in case there would be no programmatic way to get the module name. I think this solution is not very practical from a long-term perspective, because it means that every module would need to have the variable assignment line and one can easily forgot about it. But yes, it's an option 😉

@rraghvani 's suggestion is what I did back before that test name was accessible. I actually built the suite to name each module as you went in and revert to the last one as you came out and I used it in the log. It made for a very organized log that was broken into modules and easy to debug. You'll also find out quickly if you forgot it somewhere because the log isn't pretty any more. 😉


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
cancel
Showing results for 
Search instead for 
Did you mean: