Forum Discussion

KazakovMaxim's avatar
KazakovMaxim
New Contributor
9 years ago

Problems with OnLogError and Debugging with a few test items

Hello. 

I have compiled testing project with debug info and then I have created 3 test items:

1 - Start application

2 - execute routine from sctipt (it thows exception purposely)

3 - Terminate application

 

Problems:

 

After finish project with these test items in log I see:

For the 1-st test item there is debug information in log (loading dll-s and etc)

For the 2-nd there are no any debug info, only event messages. Why does it so? Though in this test item exception throws, but due to no debug info test item finished  successfully.

 

Ok, then I decided to start only the script to check the debug info is working:

Before this I set event handle OnLogEvent with this code:

Runner.Stop(true);

After execute I've obtain interesting result:

Debug info is in log - that's OK. But Errors in log:

Is that looks strange, isn't it? :)

In Information field "Error: 1", but no one error in log messages.

 

When I drop OnLogError handler it works fine.

 

I will be very grateful for any assistance! Thanks!

 

 

  • baxatob's avatar
    baxatob
    Community Hero

    Hi,

     

    In your case OnLogEvent calls Runner.Stop() immediately after the first event was occurred. And your test stops before the error was posted into the log. I suppose that the OnLogError event is more suitable here. 

    • KazakovMaxim's avatar
      KazakovMaxim
      New Contributor

      Thanks for reply.

      I made a mistake when I descripted my problem. I'm actually using OnLogError, not OnLogEvent.

       

      The main problem is debug info not works for all test units excluded the first one.

       

       

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        If I understand the OnLogError event, it intercepts the logging process at the moment it needs to log the error BEFORE the error is written to the log.  This allows you to do other processing and stuff before continuing on. So, if you're stopping the test run before the error is written, then you'll get the behavior you're seeing.

        In your event handler, you might want to make sure you flush the error to the log FIRST before you do the Runner.Stop call.

        Again... this is conjecture so someone else might correct me but I'd give that a shot.