Fitnesse中的symbols和variables

 

1.symbols 主要在表间传递信息,作用于一个page中,类似于局部变量

SaveRecordInDatabase
name date =key?
Bob today bobKey
Bill later billKey

 在方法名前加=表示要把结果存储在symbol中,而不是跟方法的返回结果作比较

FetchRecordsFromDatabase
key= fetch() name date
billKey true Bill later
bobKey true Bob today

 在入参的列中加入=表示使用单元格中的symbol值

symbol是在测试执行中赋值

 

2.variables 类似全局变量,只要在父级页面定义了,就可以在子级页面使用

定义的方法主要有三种

  • !define var {text} - as a delimited block of text
  • !define var othervar - by copying the value of another variable
  • !define var {${= 10 / 2 =}} - as an expression

例子:

!define myVariable {
This is the
text of
my
variable
}
variable defined: myVariable= this is the text of my variable

!define n 10
variable defined:
n=10
!define q 2
variable defined: q=2
!define d {${= ${n}
/ ${q} =}}
variable defined: d=${= ${n} / ${q} =}
${d} is : 5
IMPORTANT: If the variables
used in the expression change than also the result changes!
!define q 5
variable defined: q=5
${d} is : 2

 

variables在测试执行前定义好,在测试过程中不会改变

posted @ 2017-03-20 15:06  老乌鸡  阅读(461)  评论(0编辑  收藏  举报