0

我正在测试具有以下 XML 作为请求的 Web 服务。

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

并期望以下 XML 作为响应。

<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>

我希望您能帮助创建具有上述 XML 格式的黄瓜功能文件。

4

1 回答 1

0

我更喜欢在功能文件中没有实际的响应/请求(您可以看到它很快变得很麻烦),但这是一个简单的示例:

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>
"""
于 2015-07-04T19:20:56.687 回答