Forum Discussion

tomas's avatar
tomas
New Contributor
14 years ago

using generel events from connected application

Hello,


I'm developing connected application, in .NET 3.5, based on http://www.automatedqa.com/support/viewarticle.aspx?aid=11477, and I need to access project logs during test run. In TestComplete project we have "General Events" object, but I'm unable - or don't know how - to get its instance and subscribe for the events. My connected application is without gui, so as far as I know I can't use approach described here: http://www.automatedqa.com/support/viewarticle.aspx?aid=11474. Also, I don't want to call connected application from test script. We are running TestComplete 7.52.


Is there any other way to accomplish this task?


One more thing - I would like to know, how to tell TestComplete to save current log for current test run.


Thank you,


Tomas Vondracek



4 Replies

  • Hello Tomas,




    To make the General Events control available from within a non-GUI application, you can add a new Windows Form to your application, make it invisible and place the General Events control on the form. Does this work for you?




    One more thing - I would like to know, how to tell TestComplete to save current log for current test run.


    By default, TestComplete saves Test Log results after the test is completed. If you want to save parts of log to a file during test run, specify the "Save log every..." option. It defines a time interval after which the log results should be automatically saved in a file. 




    If you need to export log results from a script, use the Log.SaveResultsAs method as demonstrated in the "Exporting Results From Tests" paragraph of the Exporting Test Results help topic.




    Let me know whether this is what you need.
  • tomas's avatar
    tomas
    New Contributor


    Hello Alex,


    thank you for your reply. Suggested solution does work, most of the time. Unfortunately, sometimes I get an exception:



    System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface type 'EventControl.ItcEventControl'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{04CE375E-A7E0-4E23-AF2C-7056C613D98F}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

    at EventControl.ItcEventControl.AttachToTestComplete()

    at AxEventControl.AxEventControl.AttachToTestComplete()



    I didn't find any specific circumstances, that would cause this exception so far.


    For the second point of question. The log data are actually present on the disc, but they are not visible in TestComplete suite tree. I can add them to the project however, that doesn't help me with my task. I've also noticed that function

    Connect.Integration["CloseProjectSuite"]()

    returns false. Might this be the problem? How can I save project files?


    Thanks again,


    Tomas Vondracek




  • Hello Tomas,





    We have not come across the problem before. Can you create a sample Connected application and a sample TestComplete project that works with a regular application (for example, Notepad) that illustrate the problem (both the exception and the problem with saving test results) so that we can reproduce the problem on our side? Please send the archive containing the entire project suite folder and the entire Connected application folder with source code to Support.





    One important thing is that most TestComplete runtime objects (such as Stores, Log, etc.) can be accessed via COM only during a test run. So, please make sure that you access runtime objects when the test is running. In any case, a sample project would greatly help us understand the problem.
  • tomas's avatar
    tomas
    New Contributor

    Hello,


    it seems that I solved the issues.


    1) exception in AttachToTestComplete() - it was a threading issue - my fault.


    2) project suite didn't get closed on Connect.Integration["CloseProjectSuite"]() call because Connect.StopTest() function doesn't stop test execution immediately, but I need to wait. Usually i takes about 500ms to stop test execution. Then, project suite gets closed and logs are saved just fine.


    Thank you for your assistance,

    Tomas Vondracek