2017-09-30html
1 Variables(静态变量)
1.1 定义及使用
1.2 Variable做用域
1.2.1 Variable在层次结构中的做用域
1.2.2 include对Variable做用域的影响
2 表中的Symbol(动态变量)
2.1 定义及使用
2.2 Symbol的做用域
3 Variable和Symbol的区别ide
返回post
Variables初始化有三种方式:测试
Variables使用:ui
${VariableName}
页面脚本以下:spa
!define markedUp {This is '''bold'''} ${markedUp} is expressed as: This is bold !define y {y-value} !define x {The value of y is ${y}} ${x} is expressed as: The value of y is y-value !define n {10} !define q {2} !define d {${=${n}/${q}=}} ${d} is : 5 !define q {5} ${d} is : 2
页面显示以下:code
图1 示例1展现结果htm
当Variable在页面中被调用,但当前页面没有,fitnesse会去依次去父页面寻找,若祖先页面也没找到,fitnesse会去System.properties寻找blog
示例:
http://ip:port/ HelloWorld
http://ip:port/ HelloWorld.HelloWorld1
http://ip:port/ HelloWorld.HelloWorld2
当变量在included page中时:
示例2:
层次结构下:
Contents:
其中:
把其余页面include到father页面,来测试在不一样关系中各个变量的使用范围,页面脚本以下:
!define fatherMoney {80} grandfaMoney is: ${grandfaMoney} relativeMoney is: ${relativeMoney} fatherMoney is: ${fatherMoney} motherMoney is: ${motherMoney} sonMoney is: ${sonMoney} !include .Demo.variableIncludeTest.relative !include .Demo.variableIncludeTest.grandfa.mother !include .Demo.variableIncludeTest.grandfa.father.son grandfaMoney is: ${grandfaMoney} relativeMoney is: ${relativeMoney} fatherMoney is: ${fatherMoney} motherMoney is: ${motherMoney} sonMoney is: ${sonMoney}
页面保存后展现以下图所示:
图2 include变量做用域展现结果
在图2中咱们能够得知:
Symbol是在表中定义(赋值)和使用的
示例3:
页面脚本以下:
1 !define TEST_SYSTEM {slim} 2 3 !path D:\fitnesseUtil\bin 4 5 |import | 6 |fitnesse.slim.test| 7 |util| 8 9 |script|Add|1|2.2| 10 |$result=|calc| 11 |check|calc|$result| 12 13 |script|Add|$result|2.2| 14 |$secondResult=|calc| 15 |check|calc|$secondResult| 16 |check|calc|$result|
其中:
执行结果:
图3 symbol(动态变量)的定义和使用
Symbol做用域:
示例4:
Contents:
grandfa页面脚本如示例3。father页面脚本以下:
1 !define TEST_SYSTEM {slim} 2 3 !path D:\fitnesseUtil\bin 4 5 |import | 6 |fitnesse.slim.test| 7 |util| 8 9 |script|Add|1|2.2| 10 |check|calc|$result| 11 12 !include .Demo.variableIncludeTest.grandfa 13 14 |script|Add|1|2.2| 15 |check|calc|$result|
其中:
执行结果以下:
图4 symbol做用域
示例5:
页面脚本以下:
1 !define TEST_SYSTEM {slim} 2 3 !path D:\fitnesseUtil\bin 4 5 |import | 6 |fitnesse.slim.test| 7 |util| 8 9 |script|Add|1|2.2| 10 |$result=|calc| 11 12 !define vResult {$result} 13 vResult is: ${vResult} 14 15 |script|Add|1|2.2| 16 |check|calc|$result| 17 |check|calc|${vResult}|
其中:
执行结果以下:
图5 把Symbol赋值给Variable