Forum Discussion

Raj_Qa's avatar
Raj_Qa
Contributor
14 years ago

Attach the test log and email it

Im trying to attach the test log to an email and send it to the manager, Im trying to write a script which attaches the test log which is created at the end of the script and emailed.

Using VB Scripting.

Need help!

14 Replies

  • Irina I guess thats how the function works, but Im trying to modify it such that the test executes even if something goes wrong. I am trying to call the function in different places, but no luck so far
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Raj, 



    As Gennediay mentioned, I think you're best bet is to code an OnLogError event handler so that, when an error is logged, it will still send the e-mail.  You can also look into using OnStopTest event handler as well.



    Basically, what Irina, Gennadiy  and myself are trying to say sums up like this:



    Sub Test()

    RunLine1

    RunLine2

    RunLine3 <-Error occurs here

    RunLine4

    RunSendMail

    End Sub




    If your test code looks like what is shown above, when the error occurs, nothing after that error will run.  Script code is run in sequence and so if there are any errors that cause the test to stop, it will not just fail the line but will fail the whole subroutine and skip any additional tests.  This holds true for Keyword tests as well.  Additionally, if you're using Test Items to organize your tests and there are 5 test items, the fifth one being your SendMail, if Test item 3 fails and the "Stop On Error" is set for that item, no other items after that will run.



    It's a matter of making sure you write sufficient code to be able to handle unexpected failures.  So, Event Handlers is one way... you can also, in VBScript, us On Error Resume (I wouldn't recommend it personally).  If you were using a different script language (like JScript or DelphiScript) they have try/catch/finally logic that will allow you to trap exceptions and execute code for them.



    There's not some sort of "special" way built in to TestComplete that, on error, automatically e-mail the log file so your best bet is to use the OnLogError event handler for the "easiest" way to handle this particular problem.
  • I will try using event handler, or resume on error..

    I`ll post if I make progress.



    Thanks a lot for your time Robert.