Forum Discussion

JHoreczky's avatar
JHoreczky
Contributor
13 years ago

[Resolved] Conditional assertions

Hi,

Is it possible to configure conditional assertions? For example, a request that has optional data elements will return varying responses. In such case an assertion should not run for the missing content in the response.

So basically the assertion would only run on certain conditions. Is it doable to configure this through the out of the box assertion functionality, through point and click and maybe through some properties? What other options are available to implement this? Is it feasible to implement it through assertions by groovy scripting? If yes, can you provide some example, that I can start with?


Thanks,

Joseph H.

2 Replies

  • Hi!

    Yes, it can be done with Groovy Scripting (Script Assertion), but the easiest way is probably to create an Assertion TestStep and combine two assertions in there with OR:



    That way the OR assertion will pass either if the request Lacks the optional element or if the Element is correct.

    The assertion TestStep is part of soapUI Pro 4.5.1 and is described in detail here.

    Regards

    Henrik
    SmartBear Software
  • Hi Henrik,

    Thanks for the hints! We implemented our requirement using assertions on the request step. Adding assertion steps would be beneficial because of its additional functionality, however the direct script assertions provide better diagnostic when assertion fail - so we stayed using them.


    Thanks,

    Joseph H.