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