FitNesse

TestExpression

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

scenario given page page with content content
create page @page with content @content
$IT= echo @page

scenario given page page
given page @page with content nothing

scenario given test page page
given page @page
make @page a test page

scenario given slim test page page
given page @page with content !define TEST_SYSTEM {slim}
make @page a test page

scenario page source should have link to target
check request page @source 200
ensure content contains <a href="@target"
$IT= echo @source

scenario it should have link to target
page $IT should have link to @target

scenario and it should have link to target
page $IT should have link to @target

scenario page source should have creating link to target
check request page @source 200
ensure content contains @target<a title="create page" href="@target?edit&nonExistent=true">[?]</a>

scenario it should have creating link to target
page $IT should have creating link to @target

scenario page source should contain text
check request page @source 200
ensure content contains @text
show content

scenario page source should not contain text
check request page @source 200
reject content contains @text
show content

scenario page source should match text
check request page @source 200
ensure content matches @text
show content

scenario it should contain text
page $IT should contain @text

scenario it should not contain text
page $IT should not contain @text

scenario it should contain text in line symbol
check request page $IT 200
$@symbol= line number containing @text

scenario it should match text
page $IT should match @text

scenario test results for page source should contain text
check request page @source?test 200
ensure content contains @text
show content

scenario its test results should contain text
test results for page $IT should contain @text

scenario test ressults for page source should not contain text
check request page @source?test 200
reject content contains @text
show content

scenario and should contain text
ensure content contains @text
show content

scenario and should match text
ensure content matches @text
show content

scenario and should not contain text
reject content contains @text
show content

scenario widget wikiText should render htmlText
create page WidgetPage with content @wikiText
check request page WidgetPage 200
ensure content matches @htmlText
show content

scenario the line after should come after before
check echo int $@before < $@after

scenario pass
check echo pass pass

Included page: .FitNesse.SuiteAcceptanceTests.SuiteWidgetTests.SetUp (edit)

Included page: <SuiteAcceptanceTests.SetUp (edit)

Import
fitnesse.fixtures

SetUp

Library
echo fixture
page driver


Expressions using the mark up

Syntax:

 ${= expression =} 


An expression may be a combination of constants, variables, and opertors. All internal calculations use the Java double numeric type.

Operators supported

Comment

Spaces between items are optional

Operator Argument Description
arg
constant or variable Examples: 3 12.4 4E+8 ${VALUE} ${some.var}
expr
expression
Any valid combination of arguments and optional operations and parentheses
+
expr + expr
Addition
-
-expr
Unary negation
-
expr - expr
Subtraction
*
expr * expr
Multiplication
/
expr / expr
Division
^
expr ^ expr
Exponentiation
sin
sin expr
Radian Sine of expr
cos
cos expr
Radian Cosine of expr
tan
cos expr
Radian Tangent of expr
( )
( expr )
Parenthetical grouping of an expression


Test Blank Expressions

Build blank expression page
script
start Page Builder
line ~1a:${==}~
line ~1b:${= =}~
line ~1c:${= =}~
page ExpressionPage

Render it
Response Requester
uri valid?
ExpressionPage true

Contents

Response Examiner
type string?
contents

Response Examiner
type wrapped html?
contents


Verify results
Response Examiner
type pattern matches?
contents ~1a:~ true
contents ~1b:~ true
contents ~1c:~ true



Test Single Argument Expressions

Build expression page
script
start Page Builder
line ~2a:${=3=}~
line ~2b:${= 4.2 =}~
line ~2c:${= 2E+1 =}~
line ~2d:${= 2.3E+42 =}~
line ~2e:${= 4.2E + 24 =}~
page ExpressionPage

Render it
Response Requester
uri valid?
ExpressionPage true

Contents

Response Examiner
type string?
contents

Response Examiner
type wrapped html?
contents


Verify results
Response Examiner
type pattern matches?
contents ~2a:3~ true
contents ~2b:4.2~ true
contents ~2c:20~ true
contents ~2d:2.3E+42~ true
contents ~2e:4.2E+24~ true



Test spaces around experssions

Build expression page
script
start Page Builder
line ~3a:${=1+1=}~
line ~3b:${=2 + 2=}~
line ~3c:${= 3 + 3=}~
line ~3d:${=4 + 4 =}~
line ~3e:${=5 +5 =}~
page ExpressionPage

Render it
Response Requester
uri valid?
ExpressionPage true

Contents

Response Examiner
type string?
contents

Response Examiner
type wrapped html?
contents


Verify results
Response Examiner
type pattern matches?
contents ~3a:2~ true
contents ~3b:4~ true
contents ~3c:6~ true
contents ~3d:8~ true
contents ~3e:10~ true



Test each operator

Build expression page
script
start Page Builder
line ~4plus:${= 1 + 2 =}~
line ~4minus:${= 2 - 3 =}~
line ~4unary:${= -12 =}~
line ~4mult:${= 3 * 4 =}~
line ~4div:${= 4 / 5 =}~
line ~4exp:${=%2d: 5 ^ 6 =}~
line ~4sin1:${=%5.4f: sin0.39269875 =}~
line ~4sin2:${=%5.4f: sin 0.39269875 =}~
line ~4sin3:${=%5.4f: sin(0.39269875) =}~
line ~4sin4:${=%5.4f: sin(3.14159/8) =}~
line ~4sin5:${=%5.4f: sin (3.14159/8) =}~
line ~4cos:${=%5.4f: cos(3.14159 / 8) =}~
line ~4tan:${=%5.4f: tan(3.14159 / 8) =}~
page ExpressionPage

Render it
Response Requester
uri valid?
ExpressionPage true

Contents

Response Examiner
type string?
contents

Response Examiner
type wrapped html?
contents


Verify results
Response Examiner
type pattern matches?
contents ~4plus:3~ true
contents ~4minus:-1~ true
contents ~4unary:-12~ true
contents ~4mult:12~ true
contents ~4div:0.8~ true
contents ~4exp:15625~ true
contents ~4sin1:0.3827~ true
contents ~4sin2:0.3827~ true
contents ~4sin3:0.3827~ true
contents ~4sin4:0.3827~ true
contents ~4sin5:0.3827~ true
contents ~4cos:0.9239~ true
contents ~4tan:0.4142~ true



Test parentheses

Build expression page
script
start Page Builder
line ~5a:${= 2 * 3 + 4 / 2 - 3 =}~
line ~5b:${= 2 * ( 3 + 4 ) / 2 - 3 =}~
line ~5c:${= 2 * ( 3 + 4 ) / ( 2 - 3 ) =}~
line ~5d:${= 2 * ( 3 + ( 4 / ( 2 - 3 ) ) ) =}~
page ExpressionPage

Render it
Response Requester
uri valid?
ExpressionPage true

Contents

Response Examiner
type string?
contents

Response Examiner
type wrapped html?
contents


Verify results
Response Examiner
type pattern matches?
contents ~5a:5~ true
contents ~5b:4~ true
contents ~5c:-14~ true
contents ~5d:-2~ true

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



tear down

Keyboard Shortcuts ?

×
  • t Test
  • e Edit page
  • a Add new page
  • p Properties
  • w Where used?
  • / Focus on search bar
  • s Open search page
  • g u Go to User Guide