Defining and Expressing Variables.

You can define a variable to represent any amount of text.
!define myVariable {
This is the
text of my
variable
}
variable defined: myVariable= this is the text of my variable

You express the value of a variable like this: ${myVariable}. This expression is replaced with the value of the variable.

The value of the variable is:
this is the
text of my
variable
.


If the variable value contains wiki markup, it is interpreted as the variable is expressed.

!define markedUp {This is '''bold'''}
variable defined: markedUp=This is '''bold'''
${markedUp} is expressed as: This is bold

A variable can reference other variables.

!define y {y-value}
variable defined: y=y-value
!define x {The value of y is ${y}}
variable defined: x=The value of y is ${y}
${x} is expressed as: The value of y is y-value
!define y {new-y-value}
variable defined: y=new-y-value
${x} is expressed as: The value of y is new-y-value

A variable can be copied from another variable.
!define z y
variable defined: z=new-y-value
${z} is expressed as: new-y-value

A variable can contain an expression
!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

Variable Scope

If a variable is expressed on a page, but is not found, then its parent pages are searched in order.
If the variable is not found in any ancestor pages, FitNesse will inspect System.properties.

Defining Variables In URL Input

You can define variables in the URL input by using the format of key=value (key as variable name & value as variable value). key and value can be any string values. Multiple variables can be specified separated by &.
Variable values specified in the URL input are given precedence over variables defined on the page or in System.properties for the same key.

See Restful Services

Variables on included pages

See Parameterized Includes

Difference between variables and SLIM symbols


Predefined Variables

There are several pre-defined variables that you can use on your pages.

See Variable fitnesse test, Parent Variable fitnesse test, Define Variables in System Properties test and Variables, Symbols and Include pages