Forum Discussion

SiKing's avatar
SiKing
Community Expert
14 years ago

testRunner.fail() is broken

I have reproduced everything in SoapUI 4.0.1.

I have a test case that consist only of the following Groovy step:

log.info("Start test")
testRunner.fail("Fail test")
log.info("End test")


When I run this from the UI, I get the following in the Log output:

Thu Sep 29 10:19:43 PDT 2011:INFO:Start test
Thu Sep 29 10:19:43 PDT 2011:ERROR:Failed with reason [Fail test]
Thu Sep 29 10:19:43 PDT 2011:INFO:End test

This is undesirable. The third step should not get executed!

Further, when I run this same test from the command line (testrunner.bat), I get the following output in soapui-errors.log:

2011-09-29 10:19:54,854 ERROR [errorlog] java.lang.Exception: TestCase [TestCase 1] failed without assertions

java.lang.Exception: TestCase [TestCase 1] failed without assertions

at com.eviware.soapui.tools.SoapUITestCaseRunner.throwFailureException(SoapUITestCaseRunner.java:506)
at com.eviware.soapui.tools.SoapUITestCaseRunner.runRunner(SoapUITestCaseRunner.java:410)
at com.eviware.soapui.tools.AbstractSoapUIRunner.run(AbstractSoapUIRunner.java:158)
at com.eviware.soapui.tools.AbstractSoapUIRunner.runFromCommandLine(AbstractSoapUIRunner.java:89)
at com.eviware.soapui.tools.SoapUITestCaseRunner.main(SoapUITestCaseRunner.java:115)

This is also undesirable.
  • Hi,

    If you want the script to stop executing after calling testRunner.fail(), you will need to manually do this by returning from the script:


    log.info("Start test")
    if( shouldFailTest ) {
    testRunner.fail("Fail test")
    return
    }
    //If the test is failed, this line won't be run.
    log.info("End test")


    As for the second part of your post, this is the behavior of soapUI. If a TestCase fails, an exception is thrown, regardless of the reason of failure. You say that this is undesirable, what would you prefer to happen in this scenario?

    Regards,
    Dain
    SmartBear Software