Fitnesse中的symbols和variables

本文详细介绍了测试用例中symbols和variables的作用与用法。symbols用于表间信息传递,作用范围限于一个页面,类似局部变量;variables则类似全局变量,一经定义,在整个测试过程中保持不变。文章还提供了具体的定义与使用示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

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

SaveRecordInDatabase
namedate=key?
BobtodaybobKey
BilllaterbillKey

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

FetchRecordsFromDatabase
key=fetch()namedate
billKeytrueBilllater
bobKeytrueBobtoday

 在入参的列中加入=表示使用单元格中的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在测试执行前定义好,在测试过程中不会改变

转载于:https://www.cnblogs.com/wuqm/p/6589120.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值