03-07-2011, 10:16 PM
when you create a recovery scenario, one of the things it lets you define is the "Post-Recovery Test Run Options". The instructions on this page say, "select the test run operation you want to perform when the recovery operation is complete".
The choices are:
1) Repeat current step and continue
2) Proceed to next step
3) proceed to next action or component iteration
4) proceed to next test iteration
5) restart current test
6) stop the test run
I'm thinking you could select option #1 here - repeat the current test step.
In your recovery function, just before exiting the function, you could do this (this is taken from the QTP help on "Recovery Object", "Define a recovery Scenario" and modified a little bit):
'************************************************************************************************************************
'Description:
'
'This example uses the Recovery collection to specify a set of
'recovery scenarios to associate with a new test.
'
'Assumptions:
'There is no unsaved test currently open in QuickTest.
'For more information, see the example for the Test.SaveAs method.
'************************************************************************************************************************
How this would work: you've defined your recovery scenario for the test already. Modify your existing recovery scenario definition and set "Post-Recovery Test Run Options" to "Repeat current step and continue". In the Run Settings for your test (from QTP select File->Settings and select "Run" from the "Test Settings" window. In the run Properties window, set "When error occurs during run session" to "pop up message box".
When the error occurs in your test, it calls your recovery function. The recover function does whatever you told it to do (sends an email, I guess), then (in this example) disables all recovery scenarios for this test only. When the recover function exits, it does the post-recover test run options and re-runs the step that failed. Your recovery function is disabled now, so when the QTP re-runs the current step it will throw an error but not call the recovery function. This error will cause it to display the usual error pop-up message box that lets you stop, retry, debug, or continue.
I haven't actually tried all this, but it seems like this should/might work. Let me know how it goes.
The choices are:
1) Repeat current step and continue
2) Proceed to next step
3) proceed to next action or component iteration
4) proceed to next test iteration
5) restart current test
6) stop the test run
I'm thinking you could select option #1 here - repeat the current test step.
In your recovery function, just before exiting the function, you could do this (this is taken from the QTP help on "Recovery Object", "Define a recovery Scenario" and modified a little bit):
'************************************************************************************************************************
'Description:
'
'This example uses the Recovery collection to specify a set of
'recovery scenarios to associate with a new test.
'
'Assumptions:
'There is no unsaved test currently open in QuickTest.
'For more information, see the example for the Test.SaveAs method.
'************************************************************************************************************************
Code:
Dim qtApp 'As QuickTest.Application ' Declare the Application object variable
Dim qtTestRecovery 'As QuickTest.Recovery ' Declare a Recovery object variable
Dim intIndex ' Declare an index variable
' Open QuickTest and prepare objects variables
Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object
Set qtTestRecovery = qtApp.Test.Settings.Recovery ' Return the Recovery object for the current test
' Disable all scenarios
For intIndex = 1 To qtTestRecovery.Count ' Iterate the scenarios
qtTestRecovery.Item(intIndex).Disabled = True ' Disable each Recovery Scenario (Note: the 'Item' property is default and can be omitted)
Next
' Enable the recovery mechanism (with default, on errors, setting)
qtTestRecovery.Enabled = True
'Ensure that the recovery mechanism is set to be activated only after errors
qtTestRecovery.SetActivationMode "OnError"
'OnError is the default, the other option is "OnEveryStep".
Set qtApp = Nothing ' Release the Application object
Set qtTestRecovery = Nothing ' Release the Recovery
How this would work: you've defined your recovery scenario for the test already. Modify your existing recovery scenario definition and set "Post-Recovery Test Run Options" to "Repeat current step and continue". In the Run Settings for your test (from QTP select File->Settings and select "Run" from the "Test Settings" window. In the run Properties window, set "When error occurs during run session" to "pop up message box".
When the error occurs in your test, it calls your recovery function. The recover function does whatever you told it to do (sends an email, I guess), then (in this example) disables all recovery scenarios for this test only. When the recover function exits, it does the post-recover test run options and re-runs the step that failed. Your recovery function is disabled now, so when the QTP re-runs the current step it will throw an error but not call the recovery function. This error will cause it to display the usual error pop-up message box that lets you stop, retry, debug, or continue.
I haven't actually tried all this, but it seems like this should/might work. Let me know how it goes.