Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Minimum node occurance in the response

LegacyForum
LegacyForum Posts: 1,664 ✭✭
edited December 2016 in SOAtest
Is there any way to assert minimum occurrence count of a node in the response? I only want to check if certain element is present at least once in a sequence.
Also, is there any way to change the order of the outputs in a given test?

Thanks
Tagged:

Comments

  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    Good afternoon,

    An easy workaround for your case would be to run a "Has Content" assertion on the element in question. If that element is not there, it fails with, "Element '...' could not be located or did not contain text content." For the purposes of throwing an error if the element is not present, that may be enough for you.

    Hope this helps,
    Joseph
  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    Joseph,

    When i set assertion to validate the presence i am getting error message as per your updates but the operation will fail becoz assertion is failed. if i set the assertion for 10 elements for 100 request i will get the same error for 1000 times. But, ideally all should pass but it will give fail.

    Please suggest if i am wrong.
  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    Good morning Srinivas,

    The simple solution to your setup would be to create a "Has Content" assertion on the specific element you wish to see. For example, if your response contains a minimum of 10 "ElementA" elements, you can create a "Has Content" assertion on "../elemA[10]". That way, SOAtest will check the tenth occurrence of the element, and give an error if it does not find it.

    I have included a quick example in the attachment which should give you an idea of what I described.

    Regards,
    Joseph
  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    Create an occurrence assertion. You can choose ">=" for the option "Occurrences of element must be" and for the "expected value" use "1".

    The XPath for the assertion must find all of the elements you are interested in.

    CODE
    <root>
      <a>first</a>
      <a>second</a>
      <b>third</b>
    </root>

    If you want to verify that there is one or more "a" elements, use this XPath:

    /root/a

    Which returns two elements, and therefore the occurrence assertion will succeed.

    If you want to verify that there is one or more "c" elements, use this XPath:

    /root/c

    Which returns zero elements, and therefore the occurrence assertion will fail.