Forum Discussion

Inok's avatar
Inok
Occasional Contributor
14 years ago

Howto export results in error state

In my project suite I have several projects which are triggered by cruise control in the nightly build and I want to store the results in a *.mht file.


1) Currently I use a script to save the result in a file at the end of the test. But when the test fails, the test run will be stopped and this script will not be called. How can I specify that the results will be exported anyway?


2) Using this method I have to add a script to every project. Is there a way to use one script for the suite that exports the results of ALL projects?


Thanks 

13 Replies

  • Inok's avatar
    Inok
    Occasional Contributor
    Hi everybody



    I created a solution that works for me. I have written a script which uses the events OnLogError and OnStopTest. It stores an error flag on OnLogError and writes the logs OnStopTest only if this flag is set.

    I hold this script in one project and use it from all other projects as well. To do this, I had to add the script using Drag&Drop of the MS Exporer. TC is not able to do this. Then I assigned these 2 events in every project. Attached is the script.



    Best regards

    Konrad
  • Hi Simon,



    The solution Konrad suggested is the most reliable approach to export the whole test execution log despite the playback errors.



    Summing up the recommendations already given here, you can act in the following way:



    First of all, organize your tests into Test Items. Set the correct order of your projects and routines in the corresponding Test Items editors. For additional information, please see the 'Test Items Page (Project Suite Editor)' and 'Test Items Page (Project Editor)' articles.



    If you don't want to stop the test execution on the first error, you can disable the 'Stop on error' project suite option and set the 'Stop on error' and 'Stop on exception' options for all test items to 'None'. In this case, the test execution will be continued despite errors. For more information, please see the 'Project Properties - Playback Options' and 'Stopping Tests on Errors and Exceptions' articles.



    Then, to make TC export the whole project suite execution log, perform the actions below:

    1. Add the OnStopTest event handler to your project.

    2. Declare a global variable that contains the name of the last test item in the sequence, and if this name is equal to the name of the current test item (Project.TestItems.Current.Name), save the log contents in the OnStopTest event handler.



    After performing the scenario above, the log will contain results of the execution of all test items.



    I hope this helps.



    BTW, we've recently released a new product version. You can learn more about TestComplete 9 here.
  • konrad : "I
    created a solution that works for me. I have written a script which uses
    the events OnLogError and OnStopTest. It stores an error flag on
    OnLogError and writes the logs OnStopTest only if this flag is set."
    No need to set a flag in LogError event handler. Use Log.ErrCount in StopTest event handler.



    I found out different scenario where I need to save my log.


    1. Log is on Error,

    2. Last TestItem to be run (+1 Lexi)

    3. Delay since the last save > 5 minutes


    I think the last one should not be removed. In our case, we are able to follow TestExecution logs directly in a browser as we save log result on a web server. Keep in mind Log.SaveResult is a stupid function as it save every single file from the beginning of the execution... When you run TestExecute for several hours, you are going to save the log several times and the execution time will become exponential... (especially if you save it when the test item failed...)


    Guillaume.