1

Goal

I want "regular" test steps to break the SoapUI test case while a distinct subset of test steps should be allowed to fail.

Rationale

I have a SoapUI test case that performs a rather complicated functional test where some optional details are checked by additional JDBC test steps. Since these details are "optional", the test case should not fail (i.e. it should turn green) even if one or more of these JDBC tests fails.

Almost there

If the requirement would allow all test steps within the test case to fail, I could simply toggle the test case behaviour:

Open the TestCase Options dialog (from the TestCase toolbar) and uncheck the Abort on Error option. When you run the TestCase that step still fails but SoapUI will continue running through the other TestSteps Functional Tests | Data-Driven Tests (SoapUI.org)

Question

  • Can this goal be achieved by a setting or property on test step level (especially: without Pro version)?
  • Is there a Groovy solution similar to setFailOnError/setFailTestCaseOnErrors methods on WsdlTestCase but on test step level?
fheub
  • 249
  • 5
  • 14

2 Answers2

1

I have solved it by inserting two Groovy test steps that

  1. store the current test case settings on (temporary) test case custom property fields;
  2. turn of the error behavior before the optional steps;
  3. restore the previous error behavior after the optional steps from the (temporary) properties.

Before: disableFailOnErrorBehavior.groovy:

testRunner.testCase.with {
    // Store current TestCase options in (temporary) TestCase properties.
    setPropertyValue('_failOnError', failOnError.toString())
    setPropertyValue('_failTestCaseOnErrors', failTestCaseOnErrors.toString())
    log.debug "Saved FailOnError behavior: ${failOnError}, ${failTestCaseOnErrors}."

    // Allow following TestSteps to fail without aborting the TestCase immediately.
    setFailOnError(false)
    setFailTestCaseOnErrors(true)
    log.info "Set FailOnError behavior: ${failOnError}, ${failTestCaseOnErrors}."
}

After: restoreFailOnErrorBehavior.groovy:

testRunner.testCase.with{
    // Use (temporary) TestCase properties to restore initial TestCase options.
    setFailOnError(getPropertyValue('_failOnError').toBoolean())
    setFailTestCaseOnErrors(getPropertyValue('_failTestCaseOnErrors').toBoolean())
    log.info "Restored FailOnError behavior: ${failOnError}, ${failTestCaseOnErrors}."

    // Remove (temporary) TestCase properties.
    removeProperty('_failOnError')
    removeProperty('_failTestCaseOnErrors')
    log.debug "Clean up temporary properties: done."
}

These scripts rely on two methods to change the test case behavior:

fheub
  • 249
  • 5
  • 14
  • i tried this but it did not worked for me. i have added the first code in the groovy script. I can see the 2 properties got set at testcase level.. When i run the testcase , this step fails due to some functional issue as expected and execution stops even though both properties are set. The next step should have run as the properties are already set at testcase level – Gaurav Khurana Feb 15 '18 at 10:52
  • 1
    @Gauravkhurana the properties `_failOnError` and `_failTestCaseOnErrors` are just used to store the current state of the testcase so that we can restore the initial behavior afterwards. The core functionality of these scripts lies in invoking `setFailOnError()` and `setFailTestCaseOnErrors()` on the TestCase object. i.e. don't rely on the properties, because they are not updated e.g. if you change the TestCase behavior manually (Options dialog). – fheub Feb 16 '18 at 14:19
-1
  • Right Click on Test Case;
    Select Options; Under Basic Tab -- Deselect Abort on Error [If it is checked]
Sri Chakra
  • 11
  • 2