!include -c .FitNesse.SuiteAcceptanceTests.SetUp ---- A Scenario table is a table that can be called from other tables; namely ScriptTable and DecisionTable. The format of a Scenario table is the same as the format of a ScriptTable, but with a few differences. You can see a Scenario table in action [[here][.FitNesse.SuiteAcceptanceTests.SuiteWidgetTests.SimpleWidgets]]. !4 Declaring Scenarios using ''Interposed'' style The basic format looks like this: !| scenario | widget | wikiText | renders | htmlText | | create page | WidgetPage | with content | @wikiText | | check | request page | WidgetPage | 200 | | ensure | content matches | @htmlText | | show | content | !***> No Peeking | script | page driver | *! The first word in the table is ''Scenario''. Following that is the signature of the scenario. This signature is a lot like a function declaration. The name of the scenario in the table above is ''!-WidgetRenders-!'', and it takes two arguments: ''wikiText'' and ''htmlText''. Notice how this looks a lot like a function call in a ScriptTable. The name is composed of every other table cell appropriately camel-cased. The arguments are the interposed cells, also appropriately camel-cased. Scenario names will be camel-cased with a leading upper-case letter. Arguments will be camel-cased with a leading ''lower-case'' letter. !4 Declaring Scenarios using ''Parameterized'' style. You can also declare a scenario by embedding underscores within a string. Each underscore represents an argument. The arguments are named in a comma separated list in the following cell. !| scenario | widget _ renders _ | wikiText,htmlText | | create page | WidgetPage | with content | @wikiText | | check | request page | WidgetPage | 200 | | ensure | content matches | @htmlText | | show | content | The body of the scenario uses the arguments by prefixing them with an '@' sign. The token that follows the '@' ''must be the camel-cased name of the argument.'' Arguments that share a common root string can use optional braces to force the correct evaluation of the full name of the argument. Thus, if you have arguments ''job'' and ''job code'', you can use @{jobCode} to make sure you get the argument with the longer name. !4 Invoking a scenario from a DecisionTable !| widget renders | | wiki text | html text | | this is ''italic'' text | this is italic text | italic widget | | this is '''bold''' text | this is bold text | bold widget | Notice that the name of the decision table, once camel-cased, will be ''!-WidgetRenders-!''. Since this is the name of the above scenario, the scenario will be called rather than a fixture. This is important! Remember that if a scenario is on your page, or included into your page, then its name will override any fixture that has the same name. Scenarios come first! If you'd rather you can reference the scenario with parameters so long as you make sure the argument names in the reference exactly match the argument names in the declaration. For example the above test could have been written as: !| widget | wiki text | renders | html text | | wiki text | html text | | this is ''italic'' text | this is italic text | italic widget | | this is '''bold''' text | this is bold text | bold widget | The column headers of the DecisionTable are named for the arguments of the scenario (again, once properly camel-cased). The scenario processor simply replaces the arguments in the scenario with the contents of the table cells below the corresponding header. If you hit the test button, you will see the scenario operate. It's pretty self-explanatory. If you look at the resulting DecisionTable you'll see that an extra column has been added to each row. That column contains a collapsed section with the entire scenario table with all the arguments replaced. You can expand it by clicking on the litte arrow. Try it. !5 Output parameters You can also use ''output parameters'' with scenarios. These are basically symbols you assign in the scenario that you can then refer to in the decision table by creating a column whose name ends on '?'. This allows you to capture values in your scenario, making the symbols filled explicit and allowing different comparisons (for instance equality, greater than, etc) in different rows. !| scenario | widget _ renders _ code _ | wikiText,htmlText,responseCode? | | create page | WidgetPage | with content | @wikiText | | $responseCode= | request page | WidgetPage | | ensure | content matches | @htmlText | | show | content | !| widget renders code | | wiki text | html text | response code? | | this is ''italic'' text | this is italic text | 200 | | this is '''bold''' text | this is bold text | > 100 | !5 Constructor parameters When all rows in a decision table need to set the same value for some parameters these can be specified using ‘’constructor parameters’’, instead of repeating them for each row. This can make the decision tables more readable. In the example below the input variables "wiki text" and “html text” are given on the table construction line and not repeated in each row. !| widget renders code | given | wiki text | this is ''italic'' text | html text | this is italic text | | response code? | | 200 | | > 100 | The Syntax is - Scenario Name - !-[given|having]-! - 1. Variable Name - 1. Variable Value - 2. Variable Name - 2. Variable Value - .... To ensure backward compatibility constructor parameters are first checked if they are part of a scenario name. If a senario is found it will be used and no constructor values are passed. Only if no such scenario is found the constructor parameters can be used. !4 Invoking a scenario from a script table using ''Interposed'' style !| Script | | widget | !3 hello | renders |