Forum Discussion

Bob's avatar
Bob
Contributor
14 years ago

fail test case using groovy but dont abort

I have a number of test cases using groovy.

I want to be able to have the test case fail but to carry on with the rest of the script.  Tried using:

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

but that aborts the test case even if teh abort on error is unchecked.

Any ideas?

5 Replies

  • M_McDonald's avatar
    M_McDonald
    Super Contributor
    How about:

    [tt:3vhomiqo]assert false : "It didn't work"[/tt:3vhomiqo]
  • Bob's avatar
    Bob
    Contributor
    Thanks for the suggestion but that too causes the test case to abort 
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi,

    Unchecking the "Abort on error" option in combination with the

    assert false

    script worked ok for me, ie the step failed but the testcase continued.

    are you using on older version?

    regards!

    /Ole
    eviware.com
  • abhishek813's avatar
    abhishek813
    Frequent Contributor
    assert false : "Test Case Failed" statement works for me and i do not have the abort on error checked.
  • Hmmm, Bob, what's about this (I use JavaScript but I sure it is easy to perform this in Groovy)?

    testStatus = true;
    .......
    if (something)
    testStatus = false;
    ........
    if not (testStatus)
    testRunner.fail()

    So I use testRunner.fail only as final lines of the code.