Forum Discussion

tbom's avatar
tbom
Contributor
13 years ago

continue with next iteration on error

Hi



 We have a smoketest written in TC, where we run all our keyword tests (6 in total) from one single testscript instance (jscript).



We have done it this way, because at startup the user is presented with options to which test cases he wants to run. All tests are run using TestExecute, so this is an easy way of configuring the test scope at runtime.



Now the next problem, is that we want our script to continue to the next keyword test, if the current one fails, I have been looking at the onLogError event handler, and runner.stop() / runner.halt().. but they all seem to quit the whole test run, Where I had in mind that it should stop the current test iteration, and continue to the next.. (lets say that the test count is set for 100 on the test items page).



That is, if there is an error, quit the current iteration, and start over on the next..



We handle application shutdown / restarts, so there is nothing leftover from the failed tests..



Is this possible?

7 Replies

  • tbom's avatar
    tbom
    Contributor
    Hi



     In theory that could work, but I want to abort the current iteration of the test, and skip to the next one.



    If we fail at some point in the iteration, we don't know what state we are in. If we have stop on error switched off, we just continue the current script, doing things that might not be possible (Or having long delays waiting for GUI events that doesn't happen).



    At the start of every iteration, I kill the application that we test, to be sure that we get a fresh clean state for each test that is performed.



    / Thomas
  • irina_lukina's avatar
    irina_lukina
    Super Contributor

    Hi Thomas,

     

    >> I want to abort the current iteration of the test, and skip to the next one.


    If you need to do this, there is only one approach that may help:

    1. Divide your JScript that calls keyword tests into several parts: the part that precedes the keyword tests' call and the part that follows it. Save the first part of the script to an individual routine (for example, Test1), and the second part - to another routine (for example, Test2).
    2. Open the Test Items editor.
    3. Add and enable the following test items:
      * Test1
      * KeywordTest1
      * KeywordTest2
      * KeywordTest3
      * KeywordTest4
      * KeywordTest5
      * KeywordTest6
      * Test2
    4. Add the OnLogError event handler to your test and specify the following code in this handler:

    Runner.Stop(true);

    5. Disable the Stop on error project property.
    6. Run the entire project.

     

    Does this help?

    • Jimbo's avatar
      Jimbo
      Occasional Contributor

      Hello,

      As of TestComplete 12 the Stop command no longer appears to take an input parameter. I get a jscript error when running this. So instead I tried this:

       

      Runner.Stop();

      This stops the entire suite instead of just going to the next keyword test.

       

      So the question remains, how do we skip the remaining steps of one keyword test and go to the next one?

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        According to the help, Runner.Stop takes a boolean parameter of either "true" or "false" to indicate whether or not to stop just the current test or the whole suite.

         

        I just tried a Call Object Method operation in a keyword test in a JavaScript project where I passed the parameter "true" to the method and it worked without error.