fitSharp
Define Fixture
The Define fixture creates reusable test procedures that can be run by other fixtures. See Fixtures Using Procedures.

We declare the procedure name in the first row of the Define table and write the procedure body as the rest of the table:
|define|changename|
|set|name|Bob|
We can also declare parameters in the first row. This uses the Do Fixture style, where alternating cells make up the procedure name and the parameter names:
|define|check field|fieldname|is|expected|
|check|fieldname|expected|
To invoke the procedure, we use the procedure name in any place where we'd use a fixture or domain method name. The test results include an expandable section showing the details of the procedure execution. This is what it looks like:

when test is

story test fixture
checktest result
definechangename
setnameBob

definecheck fieldfieldnameisexpected
checkfieldnameexpected

sample domain
changename
check fieldnameisBob

definechangename
setnameBob

definecheck fieldfieldnameisexpected
checkfieldnameexpected

sample domain
changename

setnameBob
check field

checknameBob
nameisBob

definechangename
setnameBob

definecheck fieldfieldnameisexpected
checkfieldnameexpected

sample domain
changename
check fieldnameisBob
then result is
definechangename
setnameBob

definecheck fieldfieldnameisexpected
checkfieldnameexpected

sample domain
changename

setnameBob
check field

checknameBob
nameisBob

We can define a multi-table procedure body by placing nested tables in the first cell of the second row of the Define table.

when test is

story test fixture
checktest result
definetestnamenewname

setnamenewname

checknamenewname

sample domain
testnameBob

definetestnamenewname

setnamenewname

checknamenewname

sample domain
testname

setnameBob

checknameBob
Bob

definetestnamenewname

setnamenewname

checknamenewname

sample domain
testnameBob
then result is
definetestnamenewname

setnamenewname

checknamenewname

sample domain
testname

setnameBob

checknameBob
Bob

To return a value from a procedure, we use the return keyword.

when test is

story test fixture
checktest result
definechangenamenewname
setnamenewname
returnname

sampledomain
showchangenameBob

definechangenamenewname
setnamenewname
returnname

sampledomain
showchangename

setnameBob
returnname
Bob Bob

definechangenamenewname
setnamenewname
returnname

sampledomain
showchangenameBob
then result is
definechangenamenewname
setnamenewname
returnname

sampledomain
showchangename

setnameBob
returnname
Bob Bob
© Copyright Syterra Software Inc. All rights reserved.