Ask a Question

How to automatically stop the whole test project when one step is dead

Judychen2020
New Contributor

How to automatically stop the whole test project when one step is dead

Now we are using Test complete for embedded software testing. we write a dll for communicating with the product. When doing robustness test, some step may cause the product crashed down. Then we can't get any response for the next step. Then the whole test project is crashed. Do we have any way to setting the timeout for the whole project?

5 REPLIES 5
AlexKaras
Community Hero

Hi,

 

Not sure, but maybe Runner.Stop / Runner.Halt method(s) will help...

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

Thanks for your nice help. But it seems the runner.stop does not help.

 

The script is as below:

Function gettime()
Err.Clear
On Error Resume Next

i=1
while i<100
BuiltIn.Delay(1000)
if Err.Number<>0 Then
Log.Error Err.Description
Runner.Stop(CurrentTestOnly=True)
'Else
'Log.Message(" no error")
end If
i = i+1
wend

End Function

 

and I tried to use this function as below. I set a timeout for the project Save Result File to 1 min. But the whole test executed for 100s. And it seems the Runner.stop() does not help. Do you have any good advice?

Judychen2020_0-1617696946909.png

 

 

Thanks

-Judy

Hi Judy,

 

I set a timeout for the project Save Result File to 1 min.

Could you clarify what exact setting you have set to 1 minute?

 

Notes as for your code:

-- On Error Resume Next at the beginning of a function is extremely not recommended approach in VBScript because it obscures all possible problems. Error handling in VBScript is miles away from been convenient and the recommended sequence is like this:

On Error Resume Next
<code that might fail with runtime error>

iErr = Err.Number

IF(iErr <> 0) Then

  strErrDescr = Err.Description

  On Error GoTo 0

  ...

End IF

On Error GoTo 0

...

The reason for the above code is that Err object is internally (re)set after every executed line of code and thus one must store the state of the Err object *immediately* after execution of the line that might fail and then continue to work not with the Err object itself, but with the saved 'copy' of it.

 

-- if Err.Number<>0 Then

I see nothing in your code that might fail during runtime with *runtime* error and thus it is expected for me that your code never enters this IF block and thus Runner.Stop() is not called.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

Hi AlexKaras:

Thanks for your nice help. I am sorry for describing the case not clear.

I set the timeout to 1 min for the Save Result File in the column named Timeout, min. When running the project, we can see the error "The execution timeout has expired. " in the log. But as you said, the Err.Number didn't change. Then we didn't get into the if condition.

Judychen2020_1-1617756287929.png

 

 

Hi,

 

So, if I got you right, the behavior that you observe is correct, expected and is as following:

-- Test Item that exceeded Timeout set for it posts an error to test log and continues to run. This Test Item is not stopped because TestComplete does not stop test item that timed-out but just generates the OnTimeout event as documented. You may implement the handler for the OnTimeout event and stop test item (or the whole test run) if you need;

-- Next Test Item is started to be executed because the On Error setting for the timed-out Test Item is set to 'Continue running' value.

 

Is the above scenario correct?

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
cancel
Showing results for 
Search instead for 
Did you mean: