Forum Discussion

SSI's avatar
SSI
Occasional Contributor
13 years ago

Test Execute Export Log

We are running tests  with test execute  from a vb .net program  using the com interface.  is there a way to export the log files generated  with teh com object?

3 Replies

  • SSI's avatar
    SSI
    Occasional Contributor
    Jared

      i have tried that  but the object never gets set.  what am i doing wrong?



    the tests it is running  are keyword tests  the getobjectby name mentioned something about it will not return anything unless the test is running scripts



    Remarks




    The method returns the program object only if TestComplete is running script routines. If the script code is not running, the method returns an empty Variant value.





    here is what i have tried.  the suite opens correctly and the test runs correctly

    Dim ObjLog As Object = Nothing


    Try


    Call WriteLog(LogFile, "Running test")


    TestCompleteObject.Integration.RunProject(TestProject)


    ObjLog = TestCompleteObject.Integration.GetObjectByName("Log")


    Catch ex As Exception


    TestCompleteObject.Quit()


    Call WriteLog(LogFile, "Error: " & ex.Message.ToString)


    End Try


    ' do not move on until test is finished running


    Do Until TestCompleteObject.Integration.IsRunning = False


    Application.DoEvents()


    Loop


    Dim LogFileName As String = "C:\ExportLog\Test.mht"


    ObjLog.SaveResultsAs(LogFileName, 2) 'lsMHT)


    ObjLog = Nothing


    Call WriteLog(LogFile, "Finished Running test")


    Select Case TestCompleteObject.Integration.GetLastResultDescription.Status


    Case TC_LOG_STATUS.lsOk


    Passed = True


    Case Else


    Passed = False


    End Select


    Thanks

    Lynn
  • Hi Lynn,



    The Log object is available when TC is in script running state. You need to use it while the test is running. There's no documented way to export logs if TC is not in the running state, however, the Integration object provides a way to do this. It is an undocumented way which will be suitable in your case.



    After the loop which checks the running state, replace the SaveResultsAs call with the following line:

    Call TestCompleteObject.Integration.ExportLastResult("{C32B59B0-6AD4-4921-A545-021C7B76E526}", LogFileName)




    The first parameter is a GUID which corresponds to the MHT format of exported logs. The value hard-coded in this example will work if you export logs to MHT, and won't allow using other formats.