Forum Discussion

sravsand's avatar
sravsand
New Contributor
8 years ago
Solved

how to make other test steps pass/fail from groovy test step

Hello,   I have two steps in a test suite, one is soap request without any assertion other one is groovy test step. I want to make fail the soap request from groovy test step. I need how to write g...
  • JHunt's avatar
    JHunt
    6 years ago

     

    Hi again,

     

    I think you wanted to also show red/green icons in the Test Case editor for the SOAP test steps. So I was researching the source code, but it's next to impossible without Assertions on the SOAP test step. In the SoapUI source code, the icon displayed is calculated from the Assertions with every update.

     

    You can change the status of the test result, and that will display red in your Test Case Log, with an optional message.
     

    import com.eviware.soapui.model.testsuite.TestStepResult.TestStepStatus
    
    def myStep = context.testCase.getTestStepByName("Test Request 1")
    def myResult = testRunner.results.find { it.testStep.is(myStep) }
    myResult.setStatus ( TestStepStatus.FAILED )
    myResult.addMessage("Failed coz I said so.")

    But I don't recommend modifying statuses in this way. It's best to let SoapUI do that sort of stuff itself, because we're bound to miss things doing it manually. For a ready example, the overall test still shows as OK, even when we mark the test as failed (project attached). We would need to make the Groovy script step mark the TestCase as failed also. And so on...