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.

Using a value from the request to check the response through Asserter

Options
LegacyForum
LegacyForum Posts: 1,664 ✭✭
edited December 2016 in SOAtest
I am trying to verify that certain element in the response has the same text as another element in the corresponding request. Can you please help me understand how this can be done through XML Asserter?
Tagged:

Comments

  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    Options
    Hi shaharyar,

    In general, the XML Assertor is used to enforce the correct­ness of data in an XML message, commonly returned by a SOAP Client Tool or Messaging Tool. Here's a quick example, using a simple service that echoes back everything that is sent to it:
    Open SOAtest and choose to create a new project. In the New Project Window, choose WSDL and click next.
    In the WSDL Url field, enter http://soatest.parasoft.com/echo.wsdl and click finish. A new Test Suite is created with many functional tests in it.
    In the left pane, find the echoString(string) test and select it. In the right pane, next to arg0 [Fixed], enter "Hello World" (no quotes).
    Click the Run Tests toolbar button. The test will run, and a green dot should appear next to the test, indicating that it succeeded.
    At this point, the test has run, but we don't know if the echo service returned what we expected it to. So we will use the XML Assertor Tool to validate the response. This is done by chaining the XML Assertor to the SOAP Client or Messaging Tool:
    In the left pane, right-click on the echoString(string) test and choose Add Output. The Add Output dialog opens.
    On the left, choose SOAP Envelope. On the right, choose the XML Assertor and click Finish. You will see a new XML Assertor under the echoString(string) test in the left pane (you may need to click on the + sign next to it to expand the tree).
    When the echoString(string) test runs, it generates XML output, which will be fed into the XML Assertor. The XML Assertor can then enforce data values. In this case, we want the XML Assertor to check the Result element of the response for the string "Hello World".
    Select the XML Assertor in the left pane. In the right pane, choose the Configuration tab and click the Add button.
    In the Add New Assertion dialog, choose Value Assertions on the left and String Comparison Assertion on the right. Click next.
    You should see a tree of XML elements, including the Result element. Select the Result element and click Finish. The String Comparison Assertion is added to the XML Assertor.
    In the Expected Value field, type "Hello World" (no quotes). This will check the value of the Result element against the string "Hello World".
    Select the echoString(string) test in the left pane, and click the Run Tests toolbar button. The test should run and succeed.
    You can also parameterize the values that you want to compare against each other. For example, you can add a Datasource to the Test Suite and parameterize the echoString(string) arg0 field. Then, in the XML Assertor, you can parameterize the Expected Value field to the same database column. For more on paramaterization, refer to the documentation:
    In SOAtest, click Help > Documentation. In the left pane, browse to Functional Testing > Using Data Sources in Test Suites (Parameterizing Tests).
    I hope this helps, and please let me know if you need further assistance.