• Home   /  
  • Archive by category "1"

Fitnesse Variables Assignment Of Contract

Included page: .FitNesse.SuiteAcceptanceTests.ScenarioLibrary(edit)

scenariogiven pagepagewith contentcontent
create page@pagewith content@content
$IT=echo@page

scenariogiven pagepage
given page@pagewith contentnothing
$CONTENT=echo

scenariogiven test pagepage
given page@page
make@pagea test page

scenariogiven slim test pagepage
given page@pagewith content!define TEST_SYSTEM {slim}
make@pagea test page

scenariopagesourceshould have link totarget
checkrequest page@source200
ensurecontent contains<a href="@target"
$IT=echo@source

scenarioit should have link totarget
page$ITshould have link to@target

scenarioand it should have link totarget
page$ITshould have link to@target

scenariopagesourceshould have creating link totarget
checkrequest page@source200
ensurecontent contains@target<a title="create page" href="@target?edit&nonExistent=true">[?]</a>

scenarioit should have creating link totarget
page$ITshould have creating link to@target

scenariopagesourceshould containtext
checkrequest page@source200
ensurecontent contains@text
showcontent

scenariopagesourceshould not containtext
checkrequest page@source200
rejectcontent contains@text
showcontent

scenariopagesourceshould matchtext
checkrequest page@source200
ensurecontent matches@text
showcontent

scenarioit should containtext
page$ITshould contain@text

scenarioit should not containtext
page$ITshould not contain@text

scenarioit should containtextin linesymbol
checkrequest page$IT200
$@symbol=line number containing@text

scenarioit should matchtext
page$ITshould match@text

scenariotest results for pagesourceshould containtext
checkrequest page@source?test200
ensurecontent contains@text
showcontent

scenariotest results for suitesourceshould containtext
checkrequest page@source?suite200
ensurecontent contains@text
showcontent

scenarioits test results should containtext
test results for page$ITshould contain@text

scenariotest ressults for pagesourceshould not containtext
checkrequest page@source?test200
rejectcontent contains@text
showcontent

scenarioand should containtext
ensurecontent contains@text
showcontent

scenarioand should matchtext
ensurecontent matches@text
showcontent

scenarioand should not containtext
rejectcontent contains@text
showcontent

scenariowidgetwikiTextshould renderhtmlText
create pageWidgetPagewith content@wikiText
checkrequest pageWidgetPage200
ensurecontent matches@htmlText
showcontent

scenariothe lineaftershould come afterbefore
checkecho int$@before< $@after

scenariopass
checkechopasspass

scenarioshow collapsedcontent
show@content

scenarioshow Symbolresult

scenariothenpassassertions pass,failfail,ignoreare ignoredexceptionexceptions thrown
ensurecontent matchesAssertions:<[^<]*@pass right, @fail wrong, @ignore ignored, @exception exceptions
showextract match;Assertions:<[^<]*exceptionscontents0

scenarioand celltexthas resultresult
ensurecontent matchesclass="@result">@text<
showextract match;class="[^"]+">@text<contents0

variable defined: TestSTART=@@@START: Test specific content
variable defined: TestEND=@@@END: Test specific content

scenarioand TestSystem setup iscontent
$CONTENT=echo$CONTENT @content

scenarioand setup content iscontent
$CONTENT=echo$CONTENT @content

scenarioand test content iscontent
given page$ITwith content$CONTENT @@@START: Test specific content@content@@@END: Test specific content
make$ITa test page

scenarioget HTML result
startResponse Examiner.
setTypecontents
setPattern@@@START: Test specific content[^<]*(.*>)\s*@@@END: Test specific content
setGroup1
$HTML_Result=found

scenarioget HTML input
startResponse Examiner.
setTypepageHtml
setPattern@@@START: Test specific content[^<]*(.*>)\s*@@@END: Test specific content
setGroup1
$HTML_Input=found
show collapsedget value


scenarioget collapsed executon log for pagesource
checkrequest page@source?executionLog200
showcontent

scenariowhen pagesourceis tested
checkrequest page@source?test200
show collapsedcontent

scenariowhen pagesourceis tested and HTML is extracted
when page@sourceis tested
get HTML result
get HTML input


Variables are always passed "by reference" and not "by value"

if a variable is changed on a sub page and then referenced again on the parent page the variable has the value assigned on the sub page and not the value from the parent page.

This behaviour is shown in the below examples:

Define initial values for numerator, denominator and quotient

variable defined: numerator=10
variable defined: denominator=1
variable defined: quotient=${= %3.0f : ${numerator} / ${denominator} =}.0
variable defined: quotient2=${= %3.0f : ${numerator} / ${denominator} =}.0

Included page: >VariablesRedefinedMultipleTimesOnSamePageAndUsedInSubpage(edit)

Redefine denominator

variable defined: denominator=2

Included page: TestWithVariable(edit)

To test This page three variables must be defined on the parent page: "numerator", "denominator" and "quotient"


Define variables on this sub page. They can be used on the main page

variable defined: result=77.0
variable defined: quotient4=${= ${numerator} / ${denominator} =}.0

print quotient = 5.0
print quotient2 = 5.0
print quotient4 = 5.0

eg.Division
# Test Descriptionnumeratordenominatorquotient?
Expected result is calculated with expression1025.0
Expected result is in variable1025.0
Store result in a symbol102$result=
Use symbol$result15.0

printing a variable is possible: result = 77.0
printing a symbol is not possible: result = $result

Redefine denominator

variable defined: denominator=2.5

Included page: TestWithVariable(edit)

To test This page three variables must be defined on the parent page: "numerator", "denominator" and "quotient"


Define variables on this sub page. They can be used on the main page

variable defined: result=77.0
variable defined: quotient4=${= ${numerator} / ${denominator} =}.0

print quotient = 4.0
print quotient2 = 4.0
print quotient4 = 4.0

eg.Division
# Test Descriptionnumeratordenominatorquotient?
Expected result is calculated with expression102.54.0
Expected result is in variable102.54.0
Store result in a symbol102.5$result=
Use symbol$result14.0

printing a variable is possible: result = 77.0
printing a symbol is not possible: result = $result

Check values from variables and symbols

script
#$ {numerator} has the value as defined on this page
checkecho1010
#$ {denominator} has the value as defined on the sub page
checkecho2.52.5
#$ {quotient4} has the value from expression on the sub sub page
checkecho4.04.0
#$ {result} has the value as defined on the sub sub page
checkecho77.077.0
#$ result Symbol from sub sub page can be accessed
checkecho$result4.0

Redefine numerator

variable defined: numerator=20

Included page: >VariablesRedefinedMultipleTimesOnSamePageAndUsedInSubpage(edit)

Redefine denominator

variable defined: denominator=2

Included page: TestWithVariable(edit)

To test This page three variables must be defined on the parent page: "numerator", "denominator" and "quotient"


Define variables on this sub page. They can be used on the main page

variable defined: result=77.0
variable defined: quotient4=${= ${numerator} / ${denominator} =}.0

print quotient = 10.0
print quotient2 = 10.0
print quotient4 = 10.0

eg.Division
# Test Descriptionnumeratordenominatorquotient?
Expected result is calculated with expression20210.0
Expected result is in variable20210.0
Store result in a symbol202$result=
Use symbol$result110.0

printing a variable is possible: result = 77.0
printing a symbol is not possible: result = $result

Redefine denominator

variable defined: denominator=2.5

Included page: TestWithVariable(edit)

To test This page three variables must be defined on the parent page: "numerator", "denominator" and "quotient"


Define variables on this sub page. They can be used on the main page

variable defined: result=77.0
variable defined: quotient4=${= ${numerator} / ${denominator} =}.0

print quotient = 8.0
print quotient2 = 8.0
print quotient4 = 8.0

eg.Division
# Test Descriptionnumeratordenominatorquotient?
Expected result is calculated with expression202.58.0
Expected result is in variable202.58.0
Store result in a symbol202.5$result=
Use symbol$result18.0

printing a variable is possible: result = 77.0
printing a symbol is not possible: result = $result

Check values from variables and symbols again

script
#$ {numerator} has the value as defined on this page
checkecho2020
#$ {denominator} has the value as defined on the sub page
checkecho2.52.5
#$ {quotient4} has the value from expression on the sub sub page
checkecho8.08.0
#$ {result} has the value as defined on the sub sub page
checkecho77.077.0
#$ result Symbol from sub sub page can be accessed
checkecho$result8.0

Keyboard Shortcuts

  • General

  • Test page or suite
  • Edit page
  • View page (after test)
  • Add new page
  • Go To

  • User Guide
  • Quick Reference Guide
  • Full Reference Guide
  • Recent Changes
  • Edit Mode

  • Save page
  • Cancel edit
  • Tools

  • Properties
  • Where used?
  • Versions
  • Page History
  • Focus on search bar
  • Open search page
Close

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:
    • !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
  • The variable text can span many lines as shown below:
!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

  • if you include a sub page into a main page than you can use the variables define on the main page also in the included pages.
  • If you modify a variable on the sub page then the main page will also have the modified value.
  • If you define a variable on the sub page you can reference it later on the main page.
See Parameterized Includes

Difference between variables and SLIM symbols

  • Variables are evaluated at render time, before the test executes. This allows for values to be set based on page hierarchy and other things that are purely inputs to the tests.
  • Symbols only exist at execution time. They can be changed at runtime, so are distinct from variables, which cannot.

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

Keyboard Shortcuts

  • General

  • Test page or suite
  • Edit page
  • View page (after test)
  • Add new page
  • Go To

  • User Guide
  • Quick Reference Guide
  • Full Reference Guide
  • Recent Changes
  • Edit Mode

  • Save page
  • Cancel edit
  • Tools

  • Properties
  • Where used?
  • Versions
  • Page History
  • Focus on search bar
  • Open search page
Close
User Guide Contents
Introduction - Working with the Wiki - Writing Acceptance Tests - Administration - Quick Reference Guide - Full Reference Guide

One thought on “Fitnesse Variables Assignment Of Contract

Leave a comment

L'indirizzo email non verrĂ  pubblicato. I campi obbligatori sono contrassegnati *