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.

For a XML response, how can i do a data type assertion validation?

I have started using xml assertions for the response validation. I am looking for sharp answer than generic ones saying try assertions from output.
1) I want to validate data type for the response. ( String or int or text etc)
2) I need to do data length validation
3) i need to validate actual response to the expected value response

Can you please give me the assertion type and steps to be used in this scenario? Thank you Benken in advance.

Tagged:

Answers

  • bpowell
    bpowell Posts: 4

    Here's some useful resources

    Official docs have some good information including a short video tutorial, see https://docs.parasoft.com/display/SOAVIRT20222/XML+Assertor

    Also, it's likely your questions has already been asked/answered before, so searching the forum is handy to find answers quickly.

    For the length of the data length validation see:
    https://forums.parasoft.com/discussion/2895/how-to-assert-the-length-of-the-field

    As an example I have an element in my xml called TITLE and the value is shown below:

    <TITLE>Empire Burlesque</TITLE>

    One way to do this is to add an xml assertor (add Value Assertion) to the response and edit the XPath (Selected Element) manually to check the string length, e.g.:

    XPath:
    string-length(/CATALOG/CD/TITLE/string())

    Then set the expected value accordingly. In the above example I expect the value to be 16 characters long, so I set the Expected Value to be Fixed=16. You can also add a String Comparison Assertion and check the value. I select the element from the tree (/CATALOG/CD/TITLE/string()) and set the expected value to be Fixed=Empire Burlesque.

  • Thank you Powell. This will help me. i will check it out and let you know if i face any problems. Thank you again for your detailed response.

Tagged