Forum Discussion

oychw's avatar
oychw
Contributor
14 years ago

Could we stop and testing according to functions?

Could we stop and  testing according to functions?

For example.



we have following functions.If we fail in Smoke_TestCase1(),Could We stop   Smoke_TestCase1() when Log_error and continue   Smoke_TestCase2()?





function Smoke_Main()

{

  Smoke_TestCase1();

  Smoke_TestCase2();  

}





thanks!

3 Replies


  • Hi,





    I recommend you organizing your test flow with test items. TestComplete can stop a test item when an error occurs during its execution and then proceed to the next test item. You can find information on this feature in the Tests and Test Items help topic.
  • Hi,



    You can also try something like this:



    function Smoke_Main()

    {

      Smoke_TestCase1();

      Smoke_TestCase2();   

    }



    function Smoke_TestCase1()

    {

      try

      {

          // steps for execution

          

          if(! step_passed)

            throw {message: "Can't continue test cases execution"; description: "critical error"}



          // steps, which will be executed in case everything works fine.

      }

      catch(e)

      {

        Log.Error(e.message, e.description);

      }

      finally

      {

         // execute postconditions for the test case

      }

    }



    So you can put all your steps into try..catch block, and thrown an error when you want to finish current test case execution.
  • David and John:

        thanks! I use item,now it works well.