Forum Discussion

Michael_Colclou's avatar
Michael_Colclou
Occasional Contributor
12 years ago

Runner.Stop(true) stops all tests, not just the current test

Hi

I am using test complete 9

I have two simple tests:



function test1()

{

  Log.Message("Executing test1");

}



function test2()

{

  Log.Message("Executing test2");

}





and a event handling function:



var errorInStartTest = true;



function GeneralEvents_OnStartTest(Sender)

{

  if (errorInStartTest)

  {

    errorInStartTest = false;

    Log.Error("Error occurred in OnStartTest, calling Runner.Stop");

    Runner.Stop(true);

  }



I set up a project suite containing test1 and test2

I am expecting test1 to fail because an error occurs in the OnStartTest event but test2 to run successfully. The Runner.Stop(true) call should stop the execution of the current test: test1 and go onto the next test: test2

What actually happens is test1 run and reports an error but test2 is never executed.

I use the  Runner.Stop(true) call in other places and it does stop execution of the current test and go onto the next test, so why isnt it working in this case? Could it be because the call occurs in the OnStartTest event?



thanks



Michael
  • Hello Michael,



    Have you checked your project settings, Playback tab, Runtime section ? You may want to uncheck the "Stop on error" checkbox there.



    Also, you may want to check your test items "Stop on error" value (activate it with Field Chooser).



    Hope it helps !
  • nongtik's avatar
    nongtik
    New Contributor
    I have the same problem. I don't use Test Items to drive the test suite, instead use Runner.CallMethod() to invoke each test case. In this case, how can I set StopOnError for all test cases?
  • hlalumiere's avatar
    hlalumiere
    Regular Contributor
    Unfortunately this is another example at how misadapted and inadequate the test management tools and API's are in TestComplete. Nothing to do about it but write your own tools to handle it. Ironically the management tools in TestComplete are geared towards anything BUT automated testing. They require you to babysit the process from start to finish.



    To achieve what you want, you need to run each test unit separately, which in the GUI involves pressing Play on the first test, waiting for it to finish, then pressing play on the second test. You can write your own test controller that interfaces to TestComplete trough COM and runs the tests you want. Took me about 10 hours and 1000 lines of VB code. I don't see why something similar is not already included in TC.
  • Hi Michael



    Go to project properties -> Playback setting and uncheck Stop on error check. It will solve your problem.



    Regards

    Mughees Siddiqui
  • hlalumiere's avatar
    hlalumiere
    Regular Contributor
    More or less. If there is an error, there is a good chance the wrong window is on screen, or something else went wrong that will have consequences on remaining actions of the test. Unchecking that option will let your test continue, but if you can't recover gracefully every test following the failed one will also fail.