Forum Discussion

Jorge's avatar
Jorge
Occasional Contributor
13 years ago

Export test MHT - with custom name

I need to be able to rename an export report automatically so I can easily know what has been tested and when. Also if it this Success or Failure.



What already did:



    Export report as MHT

    Add report name as [test report name + date and hour + {Success or Failure (this is my problem)}]



    { How do I know if it my test is Success or Failure before it is finished? }



7 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Define "success" or "failed".  Is it that there are no errors in your log?  Or that there are no warnings?  Or that all your tests completed, even if there were errors and warnings?  It depends upon what you mean by "success" or "failed".  All TestComplete does is report to the output what you deem necessary in the output.  It doesn't make any judgement calls on whether or not a test is "successful".  That is a subjective judgement call that the tester needs to make.  So, if you want that call to be made by the automation, you need to write some sort of code to make that determination.
  • Jorge's avatar
    Jorge
    Occasional Contributor

    I want to say many thanks for your quick answer.



    Well even if it my final status test is on warning, failed  or success, I want to grab that status and add it to my .MHT export file name, then I will be able to check the test status even if I don't want to open it.



    Here  my example, in this  line {{ success = Project.Logs.LogItem(1).Data(1). }} I'm able to play with the LogItems  but the logItem that I want is the one is not created yet, the one is still in process.



    I don't know how to explain, at all but this script is runing at the end of my test and export my current test with the name of the test on it, date, hour, and the {status result } in the file name.



    Sub exportTestAs(path)

      Dim filename, dateHour, success

      

     {{ success = Project.Logs.LogItem(1).Data(1).Scheme.Name }}



      dateHour = aqConvert.DateTimeToFormatStr(aqDateTime.Now, " %d,%m,%Y %H.%M")

      filename = Project.TestItems.Current.Parent.Name

      filename = filename & dateHour & success & ".mht"



      Log.SaveResultsAs path & filename,2

    End Sub




  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    That's kind of why I said it's up to you to determine what is a success and what is not.  What I would do is utilize the OnLogError and OnLogWarning event handlers and, in those handlers, toggle a boolean variable to indicate whether or not an error or warning was logged.  Then, in your export task, check those variables and use the results to determine what to add to your export.  Then, after the log is exported, reset your variables to FALSE and go on to your next step.
  • Jorge's avatar
    Jorge
    Occasional Contributor

    Thank you Robert.





    You are right. I was almost there I found it today and was wondering myself if it can do something with that, but now I'm sure that is my solution. I will try this wonderful idea tomorrow.





    Thanks a lot you made my day. 







  • Jorge's avatar
    Jorge
    Occasional Contributor

    Thank you Robert.





    You are right. I was almost there I found it today and was wondering myself if it can do something with that, but now I'm sure that is my solution. I will try this wonderful idea tomorrow.





    Thanks a lot you made my day. 







  • Jorge's avatar
    Jorge
    Occasional Contributor
    Thanks Robert it is working.



    I just add to event handlers and work with their diferent status



    GeneralEvents_OnLogWarning

    GeneralEvents_OnLogError



    DONE!