Forum Discussion

megha_gambhire's avatar
megha_gambhire
Contributor
13 years ago

How to skip Test and execute another if one failed.

1. I have created one framework , in which i have created several test in a single project.

2. I have created batch test, Now if any one Test failed due to reason that Object is disabled error. test complete stop executing.



Here i want to jump it to first step ( Which is my base test from which i can executre another test.



How i should handle this ?

5 Replies

  • Hi,


    To specify TestComplete's behavior in case of errors, you can use the Stop on error project option or the Stop on error setting of test items. For example, you can set the Stop on error property of an individual test item to Test Item. In this case, if an error occurs during the test item run, TestComplete will cancel execution of the current test item’s further iterations and child test items and proceed with execution of subsequent sibling items.

  • Hi Margaret ,

    I am not able to find 'Stop on error' for individual Test item. Will you please explain it.



    I have created 4 Scripts as



    1. Launch the application.

    2. Apply Filter on String value.

    3. Apply Filter on Numeric value.

    4. Apply FIlter on Date value

    .

    .

    like this.



    Now if my Second script failed, due to any reason. I want to execute 3 and 4 scripts.



    And the problem is for the 3 or 4 script, the application should go the state which is displayed after 1 script.I mean to execute 2 and 3 script base state of the application is that one which is displayed after Script 1 .



    How should i handle this ?
  • Hi,


    To know how to set the Stop on error property of the individual test item, please refer to http://smartbear.com/support/viewarticle/11001/.


    In order for Script 3 or Script 4 to run from the state which the application had after Script 1 was over, you need to correct script logic. Could you please send us the code of your script routines? We'll try to help you.

  • Hi Margaret,



    I am Recording different Test in Keyword and then converting it to Script Test.

    We have different Test cases like Configure Dataset, Filter, Create Group,Create Calculated column. I have created this in a single Project suite like



    Sub (Configure Dataset)

    .

    .

    .Some code

    .

    .

    End Sub



    Sub ( Filter)

    .

    .

    .

    End Sub



     

    In my application,  Sub(Configure Dataset) is basic Test. i.e. to execute Sub(Filter), Sub(Create Group) I want to call Sub(Configure Dataset)

    i.e. To execute Filter, Crteate Group test i want my application at the state which is displayed after executing Sub(Configure Dataset).

    This is not every time.I want to call Sub(Configure Dataset) for some scenarion only. Like if Filter Test failed due to any reason in between. In this case I can not continue next Test beacuse next test cases are executiable only when it has the base state ( I.e. the form displayed after executing  Sub(Configure Dataset) ).

    And this we want to do for specific scenarion like Failed Test cases or some other scenario. Otherwise it will execute the test in sequence.

    Basically Sub(Configure Dataset) generaly invoke my desktop application, click on some button. Once the basic form is displayed ( This is my basic state) , I can execute different Test cases from this state.Also I need to close the present application instance, because Sub(Configure Dataset) invoke new instance. 

    Will you all help me out how should i handle this ?


  • Hi,


    You can use the following approach:


    1. Disable the Stop on error option.

    2. Create an event handler for the OnLogError event. For information on how to do that, please refer to http://smartbear.com/support/viewarticle/11454/.


    Here is the handler's source code you need to use:




    Sub GeneralEvents_OnLogError(Sender, LogParams)

      ErrCount = ErrCount + 1

    End Sub


    3. Use the following script code to run your tests, but before you do, replace the comments with your test commands.




    Dim ErrCount



    Sub ConfigureDataSet

        'Performing actions with the application:

       '1. Launch the application.

       '2. Click some button. The basic form will be opened.

      

      'Calling other routines

      Filter

      CreateGroup

    End Sub



    Sub Filter

      ErrCount = 0

      'Performing the needed actions

      If ErrCount <> 0 Then

        ReturnInitialState

      End If

    End Sub



    Sub CreateGroup

      'Performing the needed actions

    End Sub



    Sub ReturnInitialState

      'Returns the application to the initial state:

      '1. Close the basic form

      '2. Click the button to open the form again.

    End Sub



    Sub GeneralEvents_OnLogError(Sender, LogParams)

      ErrCount = ErrCount + 1

    End Sub