Forum Discussion

alibaba82's avatar
alibaba82
Super Contributor
17 years ago

how to stop test case via groovy

how can i stop a running test case via groovy.

Thanks

Ali

6 Replies

  • omatzura's avatar
    omatzura
    Super Contributor
    Hi Ali!

    If you want to stop it use

    testRunner.cancel( "I'm getting tired" )

    if you want to fail it use

    testRunner.fail( "It didn't work" )

    (the string is a reason displayed in the log)

    regards!

    /Ole
    eviware.com
  • Hi!

    just call return, ie

    if( ... )
    {
    testrunner.cancel( "time to go home" )
    return null
    }

    Does that help?

    regards,

    /ole
    eviware.com
  • Beno_Iskratel's avatar
    Beno_Iskratel
    Frequent Contributor
    hi,

    let say that i have groovy with 200 lines.
    if i use testRunner.cancel( "I'm getting tired" ) at line 50, the rest of 150 lines will still execute.
    what shall i use to stop test case and also stop groovy from further execution?
    stoping groovy at certain position is in fact eveyrthing what i need.
    "assert false" will do the job, but it's not the best solution.

    regards,
    beno
  • Beno_Iskratel's avatar
    Beno_Iskratel
    Frequent Contributor
    hi ole,

    yes, you answer did help me. tnx.
    i have another question.

    for example, i have 20 different assertions in my test step.
    on place 5 is script assertion.
    can i make this script assertion stop executing the rest of assertions?

    in case that i get response: "Request is not supported in this product.", i would just like to close this test step with pass/true and prevent all other assertions to mark him red/failed.
    can this be done?

    regards,
    beno
  • Hi beno,

    sorry, this isn't currently possible but it does make good sense so I'll add it to the backlog for consideration!

    regards,

    /Ole
    eviware.com
  • Beno_Iskratel's avatar
    Beno_Iskratel
    Frequent Contributor
    hi,

    any updates about this?
    is it possible to cancel the rest of assertions that are after some script assertion?

    with best regards,
    beno