Forum Discussion

nandini9's avatar
nandini9
Occasional Contributor
8 years ago

How to save log result using "Log.SaveResultsAs" method even if the test fails

Hi,

I am trying to save the logs even for the failed tests using Log.SaveResultsAs method. But log reports are not generated for the failed tests.I tried by disabling stop on error method,even this doesn't work.

  • sanjay0288's avatar
    sanjay0288
    Frequent Contributor

    Hi nandini9,

        How are you calling Log.SaveResults as method. What you need to do add General Events-> And call the Log.SaveResultsAs method in OnStopTest events handler. I have attached a sample mht file generated using this method for a failed scenario. Hope this might be of some help

     

    • nandini9's avatar
      nandini9
      Occasional Contributor

      Thanks Sanjay...This works for me

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    TestComplete creates log entries for everything that the tests do, assuming that the actions record a log entry.  When the test stops, there should be at least an error record in the log.

     

    What is probably happening is that the log is not written to disk yet when you call your Log.SaveResultsAs method.  Go to Tools -> Current Project Properties-> Playback.  There should be an option for "Save Log every ___ minutes".  Set that to "1" minute.  This is a pretty agressive timing so there may be some performance hit in your test run.  However, this will make sure that the test log is written to disk at least every 60 seconds.  

     

    Another option is that, before you call "Log.SaveResultsAs", first call the method Log.SaveToDisk.  This will immediately flush the log to the disk.

     

    Give either of those two options a try and see what that does for you.