简体   繁体   English

FitNesse:是否需要编写夹具以在测试页面上添加和使用变量

[英]FitNesse: Is it required to write fixtures to add and use variables on test page

I am trying to add a table of variables and its values in FitNesse suite page, so that it can be used for all my tests.我正在尝试在 FitNesse 套件页面中添加一个变量表及其值,以便它可以用于我的所有测试。

I am using xmlHtttp tests for SOAP web services and fhoeben/hsac-fitnesse-fixtures (slim) for this. xmlHtttp我使用xmlHtttp测试来测试 SOAP Web 服务和fhoeben/hsac-fitnesse-fixtures (slim)。

Is it required to write separate fixtures to add a table?是否需要编写单独的夹具来添加表?

Yes you can.是的你可以。

Using a scenario allows us to generate multiple request, only changing certain values.

!*> Scenario definition
!define POST_BODY_2 { {{{
<s11:Envelope xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/">
  <s11:Body>
    <ns1:GetCityWeatherByZIP xmlns:ns1="http://ws.cdyne.com/WeatherWS/">
      <ns1:ZIP>@{zip}</ns1:ZIP>
    </ns1:GetCityWeatherByZIP>
  </s11:Body>
</s11:Envelope>
}}} }

|script|xml http test|

|table template |send request                                                |
|post           |${POST_BODY_2} |to           |${URL}                        |
|check          |response status|200                                         |
|show           |response                                                    |
|register prefix|weather        |for namespace|http://ws.cdyne.com/WeatherWS/|
|$City=         |xPath          |//weather:City/text()                       |
*!

|send request       |
|zip  |City?        |
|10007|New York     |
|94102|San Francisco|

In this example the variable zip is used so the request is sent with either 10007 or 94102.在这个例子中,使用了变量zip ,所以请求是用 10007 或 94102 发送的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM