How to re run the test failed in batch runner programatically?



  • 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.



  • Rerun failed test from launching vbscript

    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)

    Rerun from Recovery scenario

    And another possibility to restart test on fail with Recovery Scenario:

    restart test on fail in 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:

    1. On test start read external file and save value in global variable runCount
    2. Check the variable runCount is less then maxRunCount. If more - reset runCount to 0 in external file and exit test.
    3. Then goes execution of test body.
    4. Here comes an error.
    5. Recovery scenario is configured to call Recovery Function:

    enter image description here

    1. In Recovery Function runCount is incremented and saved to external file.
    2. If test executes successfully reset runCount in external file to 0

    So I think it's better to control run count from external VBScript test executor.



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2