Forum Discussion

pkudrys's avatar
2 years ago

Getting Name of Failed test in OnLogError Event



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.

6 Replies

  • rraghvani's avatar
    Champion Level 3

    If you use Execution Plan, then it works,


  • rraghvani's avatar
    Champion Level 3

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


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

  • 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 😉

    • Marsha_R's avatar
      Champion Level 3

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