Ask a Question

No Log.ErrCount when test is being stopped manually

DanNad
Contributor

No Log.ErrCount when test is being stopped manually

I've opened a support issue and but they couldnt help me on this so im hoping maybe someone here knows the solution to following problem.

At the end of each of my tests the general event OnStopTest is being called and writes some results and performance data into a sql database.
Writing into database should only happen when the test has passed without error. To check if the testrun is failed  in addition to OnLogError Event i check for Log.ErrCount inside OnStopTest function.

The only problem i cant solve is: When i manually stop the testrun following happens:
1. Test is stopped

2. OnStopTest event is being called -> Log.ErrCount is 0 (but should be > 0 || 1)

At this point -> The Test is failed but Log.ErrCount is 0 and my function writes wrong results into database
3. Error "The script execution was interrupted" is Logged after the OnStopTest Event finished (i assume that only at this point Log.ErrCount is being increased by 1)

DanNad_1-1683896699694.png


I was thinking about the OnStopTest Event (Manual Testing Events) but i dont know if this is even usable also its marked as deprecated and it'll be removed in the future so i didnt try.

Is there a way to solve this?

Thanks in advance

13 REPLIES 13
rraghvani
Champion Level 3

Log.ErrCount returns the number of error messages (that is, messages added via Log.Error) posted to the test log during the current run of the current test item.

 

In this example, I'm calling Log.Error() method twice, and Log.ErrCount shows 2 

rraghvani_0-1683896834886.png

If I stop the automation after the first Log.Error() during the 10 seconds, then Log.ErrCount shows 1

rraghvani_2-1683897267554.png

Which is normal behaviour.

 


@rraghvani wrote:

Log.ErrCount returns the number of error messages (that is, messages added via Log.Error) posted to the test log during the current run of the current test item.

 

In this example, I'm calling Log.Error() method twice, and Log.ErrCount shows 2 

rraghvani_0-1683896834886.png

If I stop the automation after the first Log.Error() during the 10 seconds, then Log.ErrCount shows 1

rraghvani_2-1683897267554.png

Which is normal behaviour.

 


Yes i undestand that and thats the problem.

 


Which is normal behaviour.

Normal behaviour doesnt mean its good.

rraghvani
Champion Level 3

Sorry, I may have miss understood. When you stop the automation, and no Log.Error() methods are called, what should Log.ErrCount be?

 

OnStopTest is different to OnTestStop event.

Log.ErrCount should be 1

Ideally the "The script execution was interrupted", which looks to me like a Log.Error should be logged at the time i click the stop button and not at the very end of the log. But probably thats not a thing smartbear is going to change in near future so i need to find a workaround for this.

rraghvani
Champion Level 3

The way I see it, is that you have a parent process being TestComplete, which spools up a child process to run the automation. When you stop the automation, you are stopping the child process, and the message "The script execution was interrupted" is coming from the parent process. Therefore, Log.ErrCount will be zero, as the child process hasn't raised an error.

 

I don't think there's a way of capturing "The script execution was interrupted"

 

 

Still not acceptable if the user has to find workaround and this makes it more difficult to work with testcomplete. Atleast give the user more control over such things by adding something that helps with such situations. Add more Global Events for example OnStopButtonClicked or OnStopTest or OnPauseTest etc.
I know its maybe a problem a minor portion of users will have but still (and this has not changed): Usability or ease of use does play a big role into customer satisfaction.

rraghvani
Champion Level 3

The same behaviour occurs in development applications such as Visual Studio, Python, Java, Eclipse, Android Studio etc - it's a design feature, the parent needs to control the child!

 

However, you can put in a feature request at https://community.smartbear.com/t5/TestComplete-Feature-Requests/idb-p/TestXCompleteFeatureRequests

Thank you for clarification. So the easy solution would be the child process to raise an error by default if the stop button is clicked and not the parent?

rraghvani
Champion Level 3

Is it necessary to stop the automation manually? What is the reason to stop the automation manually?

 

I'm just trying to understand, as there could be alternative ways or resolving what you are trying to do.

cancel
Showing results for 
Search instead for 
Did you mean: