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 input is
story test fixture
checkplain testdefine changename
set name Bob

define 'check field' fieldname is expected
check fieldname expected

'sample domain'
changename
'check field' name is Bob
define changename
set name Bob

define check field fieldname is expected
check fieldname expected

sample domain
changename
set name Bob
check field
check name Bob
name is Bob
define changename
set name Bob

define 'check field' fieldname is expected
check fieldname expected

'sample domain'
changename
'check field' name is Bob
then output is
define changename
set name Bob

define check field fieldname is expected
check fieldname expected

sample domain
changename
set name Bob
check field
check name Bob
name is Bob

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 input is
story test fixture
checkplain test|define testname newname
[

|set name newname

|check name newname
]

'sample domain'
testname Bob
define testname newname

set name newname

check name newname

sample domain
testname
set name Bob

check name Bob
Bob
|define testname newname
[

|set name newname

|check name newname
]

'sample domain'
testname Bob
then output is
define testname newname

set name newname

check name newname

sample domain
testname
set name Bob

check name Bob
Bob

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

when input is
story test fixture
checkplain testdefine changename newname
set name newname
return name

'sample domain'
show changename Bob
define changename newname
set name newname
return name

sample domain
show changename
set name Bob
return name
Bob Bob
define changename newname
set name newname
return name

'sample domain'
show changename Bob
then output is
define changename newname
set name newname
return name

sample domain
show changename
set name Bob
return name
Bob Bob
Copyright © 2022 Syterra Software Inc. All rights reserved.