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.

How to do assertion for dynamically changing field or tag?

Options

I want to do a assertion for a customer contact details.. That customer has 6 contact details. That contact detail is a parent tag under that tag many child tags are there ( like adress, pH no ,landline). In some case in the parent tag some of the children tags won't be present How to validate these kind of tags?

if we are adding more contact details with at customer also it should be validated in next run.. How to do this one?

If any one knows could you please explain in detail?

Comments

  • jakubiak
    jakubiak Posts: 798 admin
    Options

    Could you provide an example XML that illustrates with some additional information about what you are trying to test?

  • sunil_subramanian
    sunil_subramanian Posts: 40
    Options

    For example
    In the First run, the XML response is populating with 3times occurance of contact details

    Particular customer has 3contact details

    Here contact details is parent tag and others are children tag


    xyz
    abc
    USA
    765432145
    12345788

    In second occurance adressline2 tag is missing
    ContactDetails>
    xyz
    USA
    765432145
    12345788

    In third occurance landline tag is missing

    ContactDetails>
    xyz
    abc
    USA
    765432145


    Whenever the children tags missing the assertion should pass..

    When ever the occurance of the parent tag is increased/decreased it should not affect the assertion validations

    Could you please help in this??

  • jakubiak
    jakubiak Posts: 798 admin
    Options

    Here is what you can do: for each element that may or may not be there, you can do the following:

    1. Create an occurrence assertion for the element that validates that exactly 1 occurrence is present
    2. Create a value assertion to validate the value of the element
    3. Create a conditional assertion that uses the occurrence assertion for the "if" and the value assertion for the "then"

    The result will be that the value assertion will only be run if the occurrence assertion validates that the element is actually there.