In this recipe we will deal with an example of dispatching an e-mail in case the execution time of any given test exceeds the maximally assigned time frame.
To send an e-mail upon reaching the timeout, it is necessary to follow through these actions:
OnTimeout
event handler.BuiltIn.SendMail("[email protected]", "example.com", "Sender Name", "[email protected]", "Subject", "Body");
function testEmailOnTimeout() { aqUtils.Delay(62*1000); }
1
minute as shown in the following screenshot:In the result, as the one-minute timespan goes out, the timeout will trigger the e-mail dispatch.
If a timeout has been signified for the test item, as it fires, the corresponding event will be triggered. In our case, as the timeout fires, the e-mail will be sent to the following address: <[email protected]>
.
We have used 62-seconds timeout because the minimum timeout is 1 minute and our example should work for more than 1 minute. In such cases it's usually better to have some reserve (for example, 2 seconds, as we have here) to avoid casual firing of the events.
It is also a good practice to specify timeouts by multiplying the number of seconds directly in the code (as we have done here), because such constructions are more maintainable in the future.
3.137.183.210