Forum Discussion

Steven_Yip's avatar
Steven_Yip
Occasional Contributor
16 years ago

Assertions with partial wildcards?

Hi, is it possible for the open-source version of SoapUI to do assertions that combine wildcards as well as static values?

For example, if I have a SOAP response that looks like this;

  Quick brown fox


Would I be able to create an assertion that verifies the presence of the word "brown", and not care about any other text around it?

So I'm thinking my assertion would be an XPath along the lines of

  *brown*


Better yet, if wildcards work on just the value (without the XML block enclosing it), I'd use a more specific XPath to verify the response, so the value of //tag/response must be [*brown*]

Ideas anyone?

Thanks,
Steve

PS - yes this is a trivial example, but I do have a real-life application that's returning messages that include both static and dynamic text components in an element, and I really want to verify the static components.

3 Replies

  • omatzura's avatar
    omatzura
    Super Contributor
    Hi Steven,

    this is not possible currently, you would have to create a script-assertion and do this kind of validations "manually"..

    But it would be a great feature to add! How about adding the possibilty to enter regular expressions for validation? something like


      {{}}


    (the surrounding {{ }} is just a suggestion for specifying the syntax, please suggest something else if you want).

    Since text values can contain '*' it would be nice to somehow have a syntax for these simpler expressions as well.. maybe


      {[*Brown*]}


    ?

    Of course we could use the existing property-expansion syntax but that might be confusing since it wouldn't be used for expanding properties!?

    Any suggestions are welcome, what do you think?

    regards!

    /Ole
    eviware.com
  • Awesome's avatar
    Awesome
    Frequent Contributor
    this sounds great!
    so... when is it going to get implemented...
  • Steven_Yip's avatar
    Steven_Yip
    Occasional Contributor
    Hi Ole,

    Sorry for not replying sooner... I don't check the forums very often, just when I run into problems with no obvious solution, such as

    http://www.eviware.com/component/option ... 28.0    - I can send my project file for that if you like

    Anyway, yes I think your idea about adding regex's to the XPath assertion is excellent. Whatever syntax you choose is fine with me, so long as it's sufficiently documented (the User Guides are well-written, but of course they weren't designed to cover every possible scenario - especially when the power of Groovy is factored in). I do agree with you in that the regex should not share the same syntax as property expansion; that would just be confusing.

    FYI, in the meantime I did resort to using script assertion steps to perform the wildcard matching of values in responses. It wasn't too painful, since Groovy has very good XML support.

    Thanks, Steven