Forum Discussion

Ravik's avatar
Ravik
Super Contributor
11 years ago

How can stop Test Script Execution on a specific error occurs

Hi Guys,



I want to stop Test Script execution when a specific error occurs.



Currently I am Using "On Error Resume Next" method its ignore all type of error and move on next step. but I want to stop test Execution on a Specific error (I also want to skip some error while appearing at execution time).



Some time its very difficult to check all those specified conditions.

is there any generic function is available.

  • Hello,


     


    You can do as Nebti Nassim said, and, also, you can use an event handler for the OnLogError event. This event handler receives the LogParams object. Its MessageText property allows you to determine the error. So, when the specific error occurs, use the  Runner.Stop method to stop the test execution. In other cases, the test continues to run. Using this approach, make sure that you disable "Stop on Error" options in the project's properties.


    This method is described in detail in the "Stopping Current Test Item After Only Specific Errors" topic.

  • nebti_nassim's avatar
    nebti_nassim
    Occasional Contributor
    Does your specific error can happen in one case of test or more than this ? If you want to stop on a specific error that could happen at a specific point of your test, you could use a Try/Catch statement. When your error will happen, then in the Catch, test if the error catched is the right one then stop the execution of the test if it is and log the error.



    Hope that can help you, and sorry for my bad english,