Getting Name of Failed test in OnLogError Event
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Getting Name of Failed test in OnLogError Event
Hi,
This is a followup to the old question posted here:
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.
Solved! Go to Solution.
- Labels:
-
Debugging
-
Keyword Tests
-
Script Tests
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you use Execution Plan, then it works,
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Another approach is to use a global variable, set the name in each test case like so,
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 😉
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@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
