I have a certian number of scripts that i run in a batch runner. I want that if a test fails, it should run again once.
i want to programatically re run the test incase it fails or enters a recovery scenario.
Thanking you in advance.
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It only takes a minute to sign up.Sign up to join this community
You can check test run status in VBScript and start the script from command line:
cscript.exe run-test.vbs [some params]
run-test.vbs would contain something like:
Dim qtApp Dim qtTest Set qtApp = CreateObject("QuickTest.Application") qtApp.Launch qtApp.Visible = True qtApp.Open testPath, False Set qtTest = qtApp.Test Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions") qtTest.Run qtResultsOpt, True ...
Here is a the line of code you need to check after Run command:
...Not (qtTest.LastRunResults.Status = "Passed")
And rerun test in loop with two conditions
test passed or
number of runs is over
Here is a link to full run-test.vbs on git (sure you need to add your rerun part)
And another possibility to restart test on fail with Recovery Scenario:
But test will run in a loop untill it passes or forever if it always fails. After rerun all variables in test would be lost so you need to save runCount in an external file.
The sequence of steps in this case:
So I think it's better to control run count from external VBScript test executor.
If you use ALM you can define in the Execution Setting of the test what to do if the test fail.
In there "On failure" field you can choose "Do Nothing" or "Rerun the test".
If you choose "Rerun the test" the other two field are enabled.
In those fields you can define how many times the test should be rerun and a script to run to cleanup the environment between the reruns.