Forum Discussion

JMcKinley's avatar
JMcKinley
Contributor
16 years ago

Question: Force a failure in a Groovy Script?

Is there a return value or somthing iI can set to for a test case to fail (turn red)?

Thanks!

5 Replies

  • omatzura's avatar
    omatzura
    Super Contributor
    Hi!

    just throw an exception.. ie

    assert false

    regards,

    /Ole
    eviware.com
  • Maybe I'm doing something wrong... I tried this before I sent this message... when I tried this, I got a dialog box showing the failure if it failed... the test case did NOT turn red 

    Sorry for the too short email so that I did not explain properly the issue... again, instead of turning red, I got a dialog box that showed the line that failed and why... if the assert did not fail it went through as normal... the primary issue is that I don't want a dialog box in our test cases (other than maybe for debugging purposes) since they will be run in an automated fashion.

    Thanks!
    Jim
  • alibaba82's avatar
    alibaba82
    Super Contributor
    when you run through testrunner (automated command line) you will not get a dialog box. I have a few test cases where the the groovy has something like
    'throw new Exception ("foo") and it causes the test case to fail since the test step failed.

    -Ali
  • omatzura's avatar
    omatzura
    Super Contributor
    Hi,

    thanks for replying Ali!

    Jim, are you all set with this or do you need more input?

    regards,

    /Ole
    eviware.com
  • I think I am fine with this one now...

    Thanks for all the replies!