Forum Discussion

vpachpute1's avatar
vpachpute1
Frequent Contributor
8 years ago

Execution is aborted if any Groovy step is failed in between

Hi

 

I have groovy scripts i between Test Steps.

 

But if any Groovy script fails, further execution is stopped.

 

Note: In Options: I have unchecked Abort Test if an error occurs. PFA of same

 

Can you please tell me if any specific option wrt Groovy script failure.

 

Regards

Vishal

  • HKosova's avatar
    HKosova
    8 years ago

    Hi Vishal,

     

    Unchecking the "Abort test if an error occurs" option should be enough.

     

    How does your first Groovy script set the failed status? The proper way to fail a script is to use an assert or throw an exception, e.g.:

    assert somevalue == "expected value"
    
    // or
    if (somevalue != "expected value") {
      throw new Exception("Result is not as expected!")
    }

    But if your Groovy script uses testRunner.fail:

    testRunner.fail("Result is not as expected!")

    then this line stops the entire test. The "Abort test if an error occurs" option is ignored in this case.

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)

    Hi Vishal,

     

    Those steps are still executed. The gray icon simply means that these steps don't have any assertions, so Ready! API treats the test step status as UNKNOWN rather than OK/FAILED.

     

    Steps with assertions appear with the green/red icon depending on the assertion status, steps without assertions appear gray.

    • vpachpute1's avatar
      vpachpute1
      Frequent Contributor

      Hi

       

       

       

       

       

      • HKosova's avatar
        HKosova
        SmartBear Alumni (Retired)

        Hi Vishal,

         

        Unchecking the "Abort test if an error occurs" option should be enough.

         

        How does your first Groovy script set the failed status? The proper way to fail a script is to use an assert or throw an exception, e.g.:

        assert somevalue == "expected value"
        
        // or
        if (somevalue != "expected value") {
          throw new Exception("Result is not as expected!")
        }

        But if your Groovy script uses testRunner.fail:

        testRunner.fail("Result is not as expected!")

        then this line stops the entire test. The "Abort test if an error occurs" option is ignored in this case.