0

I'm working on testing the web service which has the following XML as a request.

<request>
  <customerId>ABCD1</customerId>
  <accountList>
    <account>
      <accountNumber>12345</accountNumber>
      <customerName>John</customerName>
    </account>
    <account>
      <accountNumber>54321</accountNumber>
      <customerName>Henry</customerName>
    </account>
  </accountList>
</request>

And expected the following XML as a response.

<response>
  <bankInformationList>
    <bankInformation>
      <bankId>5678</bankId>
      <bankName>ABCD</bankName>
    </bankInformation>
    <bankInformation>
      <bankId>3333</bankId>
      <bankName>MNOP</bankName>
    </bankInformation>
    <bankInformation>
      <bankId>44444</bankId>
      <bankName>POPO</bankName>
    </bankInformation>
  </bankInformationList>
</response>

I would like your help to create cucumber feature file which has the XML format as above.

sdwp
  • 1

1 Answers1

0

I prefer to not have the actual responses/requests in the feature file (as you can see it quickly becomes cumbersome), but this is a simple example:

Feature: <Description>
  As a ...
  I want to ...
  So that I ...

  Scenario: A user requests a customer account
    Given I have a request body with xml:
      """
        <request>
  <customerId>ABCD1</customerId>
  <accountList>
    <account>
      <accountNumber>12345</accountNumber>
      <customerName>John</customerName>
    </account>
    <account>
      <accountNumber>54321</accountNumber>
      <customerName>Henry</customerName>
    </account>
  </accountList>
</request>
      """
    When I post the body to the webservice
    Then the response is:
"""
<response>
  <bankInformationList>
    <bankInformation>
      <bankId>5678</bankId>
      <bankName>ABCD</bankName>
    </bankInformation>
    <bankInformation>
      <bankId>3333</bankId>
      <bankName>MNOP</bankName>
    </bankInformation>
    <bankInformation>
      <bankId>44444</bankId>
      <bankName>POPO</bankName>
    </bankInformation>
  </bankInformationList>
</response>
"""
jmccure
  • 1,180
  • 7
  • 16