!include -c .FitNesse.SuiteAcceptanceTests.SetUp !***< classpath !path classes !path lib/*.jar *! ---- 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. Notice that there is no concept of an ''output'' header; i.e. there is no '?' in any of the column headers. A DecisionTable that calls a ScenarioTable does not make any assertions of its own. Rather it relies on the Scenario table to do the asserting. If you look at the ScenarioTable above, it uses the ''check'' keyword to make the assertion. Again, this is important. When you call a Scenario, you only pass data ''into'' it. You don't get data back out of it. Scenarios have no return value. 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. !4 Invoking a scenario from a script table using ''Interposed'' style !| Script | | widget | !3 hello | renders |