![JAR search and dependency download from the Maven repository](/logo.png)
FitNesseRoot.Fitnesse.UserGuide.FitNesseWiki.MarkupLanguageReference.MarkupVariables.content.txt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of smartrics-RestFixture-LiveDoc Show documentation
Show all versions of smartrics-RestFixture-LiveDoc Show documentation
FitNesse tests documenting the RestFixture
!2 Defining and Expressing Variables.
You can define a variable to represent any amount of text.
* Variable names may contain letters, numbers, periods and underscores; e.g., MYTEST.someVar or user.name or USER_NAME
* You can define a variable in three ways:
* !style_code(!-!define var {text}-!) - as a delimited block of text
* !style_code[!-!define var othervar-!] - by copying the value of another variable
* !style_code(!-!define var {${= 10 / 2 =}}-!) - as an [[expression][MarkupExpressions]]
* The variable text can span many lines as shown below:
!style_code{!define myVariable {
This is the
text of my
variable
}}
!define myVariable {
this is the
text of my
variable
}
You express the value of a variable like this: !style_code{!-${myVariable}-!}. This expression is replaced with the value of the variable.
''The value of the variable is: ${myVariable}.''
If the variable value contains wiki markup, it is interpreted as the variable is expressed.
!style_code{!-!define markedUp {This is '''bold'''}-!}
!define markedUp {This is '''bold'''}
!style_code{!-${markedUp}-!} is expressed as: ${markedUp}
A variable can reference other variables.
!style_code{!-!define y {y-value}-!}
!define y {y-value}
!style_code{!-!define x {The value of y is ${y}}-!}
!define x {The value of y is ${y}}
!style_code{!-${x}-!} is expressed as: ${x}
!style_code{!-!define y {new-y-value}-!}
!define y {new-y-value}
!style_code{!-${x}-!} is expressed as: ${x}
A variable can be copied from another variable.
!style_code{!-!define z y-!}
!define z y
!style_code{!-${z}-!} is expressed as: ${z}
A variable can contain an expression
!style_code{!-!define n 10-!}
!define n {10}
!style_code{!-!define q 2 -!}
!define q {2}
!style_code{!-!define d {${= ${n} / ${q} =}}-!}
!define d {${= ${n} / ${q} =}}
!style_code{!-${d}-!} is : ${d}
IMPORTANT: If the variables used in the expression change than also the result changes!
!style_code{!-!define q 5 -!}
!define q {5}
!style_code{!-${d}-!} is : ${d}
!3 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.
!3 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][
© 2015 - 2025 Weber Informatics LLC | Privacy Policy