Forum Discussion

SangeetNenwani's avatar
SangeetNenwani
Contributor
3 months ago

Runner.Stop(true) stops complete execution, not just the current test case

I want to use Runner Stop to skip some test cases in specific condition during the automatic testing.
I am using Runner.Stop (true) in the event onStartTest. Project playback settings are continue runinng..
The test case item setting in the execution plan is on error; use the project on error property. 

How to solve this issue

  • lherry's avatar
    lherry
    2 months ago

    I checked with latest version, its also working for me.

    Good news !

    Can you please confirm once again is it working since 15.59? 

    Yes, I opened a ticket for this problem on May 10, 2023 on version 15.05.
    It was resolved on December 15, 2023 on version 15.59.

    It took a long time to fix, but it's been working ever since.
    Having said that, I don't think many people use this function in an event method.

  • I'm using this in my tests...

    function EventControl_OnLogError(Sender, LogParams)
    {
      // in case of error in certain module, stop logging errors/prevent test to fail
      var testModuleName=Project.Variables.currentTestModuleName;
      if (testModuleName=="ConnectionIsNotPrivate_DISMISS")
      {
        Log.Warning(LogParams.MessageText);
        LogParams.Locked = true; //disables further log messages
      }
    }

    Basically, it skips the (error) logging in case of error in given module and the test continues with next test module. Hope this helps?  

  • Jack12's avatar
    Jack12
    Occasional Visitor

    I've faced a similar issue with Runner.Stop(true) stopping the entire execution instead of just skipping specific test cases. What worked for me was using Runner.SkipCurrentTest() within the test case itself, rather than Runner.Stop(true), to bypass only the current test when a certain condition is met. Additionally, I made sure the project playback settings were set to continue running, and the flow control was adjusted in the execution plan to handle such conditions. This way, the rest of the test cases can continue to execute without interruption.

    • lherry's avatar
      lherry
      Contributor

      Hi,
      That's interesting, but where did you find the SkipCurrentTest() function?

    • SangeetNenwani's avatar
      SangeetNenwani
      Contributor

      I made use of that
      In general events, I use Runner Stop (true).
      In addition, I have set a flag to skip a few more test items through general events, until another function resets it.
      However, it stops all testing, not just one test case.

      • rraghvani's avatar
        rraghvani
        Champion Level 3

        If you are running tests via Execution Plan, then Runner.Stop may stop the entire execution plan. However, it might work if you call all your functions within a main function.

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    It's probably best to create a new project, with the logic you have defined for Runner.Stop, to see how it works. You can raise an error via Log.Error().

    If it's not working as you expect it to be, then it could be an issue with the TC version that you are using.