From bd77e260bb62007754ac75692c16dff6d8632d1f Mon Sep 17 00:00:00 2001 From: six42 Date: Fri, 17 Oct 2014 01:26:46 +0200 Subject: [PATCH] Scenario with output parameters (alpha) --- .../ParameterizedScenarios/content.txt | 22 ++- .../ParameterizedScenarios/properties.xml | 3 +- .../content.txt | 43 +++++ .../properties.xml | 13 ++ .../content.txt | 47 +++++ .../properties.xml | 13 ++ .../content.txt | 64 +++++++ .../properties.xml | 13 ++ .../ScenarioTestSuite/content.txt | 2 + .../ScenarioTestSuite/properties.xml | 14 ++ .../CalculatorRequirements/content.txt | 4 +- .../CalculatorRequirements/properties.xml | 2 +- .../content.txt | 2 - .../properties.xml | 2 +- .../SlimSymbolManipulation/content.txt | 22 +-- .../content.txt | 175 ++++++++++++++++++ .../properties.xml | 15 ++ .../SliM/ScenarioTable/content.txt | 4 +- .../SliM/ScenarioTable/properties.xml | 1 + .../SliM/SlimProtocol/content.txt | 9 + .../SliM/SlimProtocol/properties.xml | 1 + .../slim/tables/ScenarioTable.java | 15 +- 22 files changed, 438 insertions(+), 48 deletions(-) create mode 100644 FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/ScenarioTestSuite/ScenarioWithOutputParametersInDecisionTables/content.txt create mode 100644 FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/ScenarioTestSuite/ScenarioWithOutputParametersInDecisionTables/properties.xml create mode 100644 FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/ScenarioTestSuite/ScenarioWithOutputParametersInScripts/content.txt create mode 100644 FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/ScenarioTestSuite/ScenarioWithOutputParametersInScripts/properties.xml create mode 100644 FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/ScenarioTestSuite/UsingConstructorArgumentsFromDecisionTablesInScenarios/content.txt create mode 100644 FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/ScenarioTestSuite/UsingConstructorArgumentsFromDecisionTablesInScenarios/properties.xml create mode 100644 FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/ScenarioTestSuite/content.txt create mode 100644 FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/ScenarioTestSuite/properties.xml create mode 100644 FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/SlimSymbolManipulationException/content.txt create mode 100644 FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/SlimSymbolManipulationException/properties.xml diff --git a/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/ParameterizedScenarios/content.txt b/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/ParameterizedScenarios/content.txt index 552cd1b22c..9b3855b7b9 100644 --- a/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/ParameterizedScenarios/content.txt +++ b/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/ParameterizedScenarios/content.txt @@ -27,7 +27,7 @@ beat Bill with a noodle |login user with password;|Bob|xyzzy| !3 Scenarios can be defined without a filler name between the underscores -|scenario | myDivision _ _ _|numerator, denominator, quotient| +|scenario | my division _ _ _|numerator, denominator, quotient| |setNumerator| @numerator| |setDenominator| @denominator| |check | quotient| @quotient| @@ -36,16 +36,22 @@ Use the Division class from the eg library to implement the scenario |Library| |eg.Division| -Test the scenario with a decision table -| myDivision | +!4 Test the scenario with a decision table +| my division | | # | numerator | denominator | quotient | | any comment| 10 | 2 | 5.0 | +You can change the order of the columns +| my division | +|quotient | # | numerator | denominator | +| 5.0| any comment| 10 | 2 | -Test the scenario with a script + +!4 Test the scenario with a script +the order of the parameters can't be changed! |script| -|myDivision 20 5 4.0| -|myDivision |6|| 3|| 2.0| -|#| open Bug: The next syntax fails| -|#|myDivision; |10 2 5.0| +|my division 20 5 4.0| +|my division |6|| 3|| 2.0| +|my division; |35 |5| 7.0 | + diff --git a/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/ParameterizedScenarios/properties.xml b/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/ParameterizedScenarios/properties.xml index afb3ad1eb1..dd2290ea88 100644 --- a/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/ParameterizedScenarios/properties.xml +++ b/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/ParameterizedScenarios/properties.xml @@ -2,12 +2,11 @@ - + six42 - diff --git a/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/ScenarioTestSuite/ScenarioWithOutputParametersInDecisionTables/content.txt b/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/ScenarioTestSuite/ScenarioWithOutputParametersInDecisionTables/content.txt new file mode 100644 index 0000000000..3ce71f2bb0 --- /dev/null +++ b/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/ScenarioTestSuite/ScenarioWithOutputParametersInDecisionTables/content.txt @@ -0,0 +1,43 @@ +Output parameters in scenarios are flagged with a question mark in the header row, like in decision tables. +For each output parameter a symbol with the same name must be assigned a value in the scenario. + +See below a sample of a division scenario with output parameter "result" + +|scenario | my division |numerator| | denominator| | result?| +|setNumerator| @numerator| +|setDenominator| @denominator| +|$result= | quotient| + + +Get the Division implementation from the eg package +|Library| +|eg.Division| + + + +| my division | +| numerator | denominator | result? | +| 10 | 2 | $x= | +| $x | 1 | 5.0 | + + +!3 A result calculated in one row and assigned to a symbol can be used in the next row +and the order of the columns doesn't matters + +| my division | +| result? | numerator | denominator | +| $x= | 1000 | 2 | +| $x= | $x | 2 | +| $x= | $x | 2 | +| $x= | $x | 2 | +| $x= | $x | 2 | +| $x= | $x | 2 | +|7.8125 | $x | 2 | + +!3 A result can be used in multiple columns in the decion table to do different checks +| my division | +| numerator | denominator | result? | result?| +| 10 | 2 | 5.0 | < 7.0| +| 12.6 | 3 | 4.2 | > 3.0| + + diff --git a/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/ScenarioTestSuite/ScenarioWithOutputParametersInDecisionTables/properties.xml b/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/ScenarioTestSuite/ScenarioWithOutputParametersInDecisionTables/properties.xml new file mode 100644 index 0000000000..1c808ac52b --- /dev/null +++ b/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/ScenarioTestSuite/ScenarioWithOutputParametersInDecisionTables/properties.xml @@ -0,0 +1,13 @@ + + + true + true + six42 + true + true + true + true + true + true + true + diff --git a/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/ScenarioTestSuite/ScenarioWithOutputParametersInScripts/content.txt b/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/ScenarioTestSuite/ScenarioWithOutputParametersInScripts/content.txt new file mode 100644 index 0000000000..6dc6f16cdc --- /dev/null +++ b/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/ScenarioTestSuite/ScenarioWithOutputParametersInScripts/content.txt @@ -0,0 +1,47 @@ +!1 Scripts can call scenarios with output parameters + +Output parameters in scenarios are flagged with a question mark in the header row, like in decision tables. +For each output parameter a symbol with the same name must be assigned a value in the scenario. + +In the calling script you can than access the output parameter. +A scenario can have also more than one output parameter + +See below a sample of a division scenario with output parameter "quotient" + +|scenario | Mydivision |numerator| | denominator| | quotient?| +|setNumerator| @numerator| +|setDenominator| @denominator| +|$quotient= | quotient| + + +Get the Division implementation from the eg package +|Library| +|eg.Division| + +The recommended syntax to call the scnario from a script is as below + +|script| +|Mydivision; |35| 5 | +|check |echo| $quotient| 7.0| + +|script| +| Mydivision |40| | 4| | +|check |echo| $quotient| 10.0| + +The below is not recommended and might not work in the future +|script| +| Mydivision |40| | 10| | _| +|check |echo| $quotient| 4.0| + +|script| +|Mydivision; |35 |5| _ | +|check |echo| $quotient| 7.0| + + +The following syntax is currently not working +!|script| +|# Mydivision 35 5 | +|# check |echo| $quotient| 7.0| + + + diff --git a/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/ScenarioTestSuite/ScenarioWithOutputParametersInScripts/properties.xml b/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/ScenarioTestSuite/ScenarioWithOutputParametersInScripts/properties.xml new file mode 100644 index 0000000000..1c808ac52b --- /dev/null +++ b/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/ScenarioTestSuite/ScenarioWithOutputParametersInScripts/properties.xml @@ -0,0 +1,13 @@ + + + true + true + six42 + true + true + true + true + true + true + true + diff --git a/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/ScenarioTestSuite/UsingConstructorArgumentsFromDecisionTablesInScenarios/content.txt b/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/ScenarioTestSuite/UsingConstructorArgumentsFromDecisionTablesInScenarios/content.txt new file mode 100644 index 0000000000..84095eda6a --- /dev/null +++ b/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/ScenarioTestSuite/UsingConstructorArgumentsFromDecisionTablesInScenarios/content.txt @@ -0,0 +1,64 @@ +If a decision table is implemented with a class you can specify constructor arguments. +See .FitNesse.UserGuide.WritingAcceptanceTests.SliM.ConstructorArguments for details. + +If a decision table is implemented with a scenario you can specify constructor arguments as well they have the following meaning: + +|scenario | Division _ _ _|numerator, denominator, quotient?| +|setNumerator| @numerator| +|setDenominator| @denominator| +|$quotient= | quotient| + +|library| +|eg.Division| + +!3 Calling a Scenario with Constructor Parameters + +The input variable "numerator" is given on the table construction line and must not be repeated in each row. +This can make the decison tables more readable. + +| Division | having |numerator| 9| +| denominator | quotient? | +| 3 | 3.0 | +| 2 | 4.5 | + +The Syntax is - Scenario Name - [given|having] - 1. Variable Name - 1. Variable Value - 2. Variable Name - 2. Variable Value - .... + +!5 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. + +Example: + +Again a scenario with the same signature as above +|scenario | Division _ _ _|numerator, denominator, quotient?| +|check| echo | @numerator|7| + +| Division | having |numerator| 7| +| denominator | +| 3 | + +Now a higher priority scenario name +This new scenario has a name which matches the constructor parameter name "numerator". +Calling again the same decision table will use this scenario. +But numerator will not have a value. +|scenario | Division Numerator _ _ _| numerator, denominator, quotient?| +|check| echo | @numerator|@numerator| +|check not |echo| @numerator|12| + + +| Division | having |numerator| 12| +| denominator | +| 3 | + +!3 Scenario without output parameters can be used as well with constructor parameters +In this case the full line will be collered with the scenario test result. In scenarios with output parameters only the output column cells are colored. +|scenario | myDivision _ _ _|numerator, denominator, quotient| +|setNumerator| @numerator| +|setDenominator| @denominator| +|check | quotient| @quotient | + +| myDivision | having |numerator| 12| +| denominator |quotient| +| 3 | 4.0| +|6|2.0| +|4|3.0| diff --git a/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/ScenarioTestSuite/UsingConstructorArgumentsFromDecisionTablesInScenarios/properties.xml b/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/ScenarioTestSuite/UsingConstructorArgumentsFromDecisionTablesInScenarios/properties.xml new file mode 100644 index 0000000000..1c808ac52b --- /dev/null +++ b/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/ScenarioTestSuite/UsingConstructorArgumentsFromDecisionTablesInScenarios/properties.xml @@ -0,0 +1,13 @@ + + + true + true + six42 + true + true + true + true + true + true + true + diff --git a/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/ScenarioTestSuite/content.txt b/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/ScenarioTestSuite/content.txt new file mode 100644 index 0000000000..d5d4a02a01 --- /dev/null +++ b/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/ScenarioTestSuite/content.txt @@ -0,0 +1,2 @@ +!1 !help +!contents -R2 -g -p -f -h \ No newline at end of file diff --git a/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/ScenarioTestSuite/properties.xml b/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/ScenarioTestSuite/properties.xml new file mode 100644 index 0000000000..59e67fdd7e --- /dev/null +++ b/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/ScenarioTestSuite/properties.xml @@ -0,0 +1,14 @@ + + + true + true + Test suite for Scenario Defintions + true + true + true + true + true + + true + true + diff --git a/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/SegregationOfRequirementsAndImplementation/CalculatorRequirements/content.txt b/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/SegregationOfRequirementsAndImplementation/CalculatorRequirements/content.txt index fcee9a70a3..4bf69ade49 100644 --- a/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/SegregationOfRequirementsAndImplementation/CalculatorRequirements/content.txt +++ b/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/SegregationOfRequirementsAndImplementation/CalculatorRequirements/content.txt @@ -5,5 +5,5 @@ | 22 | 7 | ~=3.14 | | 9 | 3 | <5 | | 11 | 2 | 4<_<6 | -| 100 | 4 | 25.0 | -| 25.0 | 5 | 5.0| +| 100 | 4 | $R1= | +| $R1 | 5 | 5.0| diff --git a/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/SegregationOfRequirementsAndImplementation/CalculatorRequirements/properties.xml b/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/SegregationOfRequirementsAndImplementation/CalculatorRequirements/properties.xml index b4b9bbc8bd..a6cb12d142 100644 --- a/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/SegregationOfRequirementsAndImplementation/CalculatorRequirements/properties.xml +++ b/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/SegregationOfRequirementsAndImplementation/CalculatorRequirements/properties.xml @@ -3,11 +3,11 @@ true true A sub page with requirements for a calculator. + six42 true true true true - true true diff --git a/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/SegregationOfRequirementsAndImplementation/content.txt b/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/SegregationOfRequirementsAndImplementation/content.txt index 7e82aacfb4..0b4b875c60 100644 --- a/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/SegregationOfRequirementsAndImplementation/content.txt +++ b/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/SegregationOfRequirementsAndImplementation/content.txt @@ -22,10 +22,8 @@ Generate an instance of the class used by the scenario: | Library | | eg.Division| -|script | Division| We retest the requirements and get the same results. -Also the output is differently printed. !include >CalculatorRequirements diff --git a/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/SegregationOfRequirementsAndImplementation/properties.xml b/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/SegregationOfRequirementsAndImplementation/properties.xml index 761e951b1b..1c808ac52b 100644 --- a/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/SegregationOfRequirementsAndImplementation/properties.xml +++ b/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/SegregationOfRequirementsAndImplementation/properties.xml @@ -2,7 +2,7 @@ true true - sa + six42 true true true diff --git a/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/SlimSymbolManipulation/content.txt b/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/SlimSymbolManipulation/content.txt index 85908c3c2c..7bbbb1ef93 100644 --- a/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/SlimSymbolManipulation/content.txt +++ b/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/SlimSymbolManipulation/content.txt @@ -26,7 +26,7 @@ This page tests the above functions |check| echo |$copy| [[[n, 1], [2n, 2]], [[n, 2], [2n, 4]]]| |check |echo|$q|[[[n, 1], [2n, 2]], [[n, 2], [2n, 4]], [[n, 3], [2n, 6]]]| -!3 Free the symbol again +!3 Free the symbol !|script| |check| echo |$copy| [[[n, 1], [2n, 2]], [[n, 2], [2n, 4]]]| |check |echo|$q|[[[n, 1], [2n, 2]], [[n, 2], [2n, 4]], [[n, 3], [2n, 6]]]| @@ -57,27 +57,9 @@ This page tests the above functions |check | echo | $cell |[n, 2]| |$cell= | getValuefromTableResultSymbol;| $copy| 1| 1| |check | echo | $cell |[2n, 4]| +|check | getValuefromTableResultSymbol;| $copy| 1| 1| [2n, 4]| -!3 No index out of range is crashing the slim client or wiki server -Also after an exception the value of a variable stays in sync between clint and server - -|script| -|$cell= | getValuefromTableResultSymbol;| $copy| 2| 1| -|show | echo | $cell || -|$clientCell= | cloneSymbol| $cell| -|check | echo | $cell |$clientCell| - -|script| -|$cell= | getValuefromTableResultSymbol;| $copy| 1| 2| -|show | echo | $cell || -|script| -|$cell= | getValuefromQueryResultSymbol;| $copy| 4| 2n| -|show | echo | $cell || - -|script| -|$cell= | getValuefromQueryResultSymbol;| $copy| 1| nix| -|show | echo | $cell || !3 Free the $copy, the $cell value must not be impacted |script| diff --git a/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/SlimSymbolManipulationException/content.txt b/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/SlimSymbolManipulationException/content.txt new file mode 100644 index 0000000000..57cd1b3183 --- /dev/null +++ b/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/SlimSymbolManipulationException/content.txt @@ -0,0 +1,175 @@ +!1 Positiv Test Case: No Error no exception +Check that the test page we build internally is 100% correct. + +This makes sure that the exceptions we get in the negativ test cases are related to the functionality we test and not the setup +!| script | +| given page | TestPage | with content | ${SUT_PATH} !- +!define TEST_SYSTEM {slim} +| import | +| fitnesse.slim.test | + +!|Library| +|EchoScript| + +!|script| Test Query| 2| +|$sq= | query| +|$scell= | getValuefromQueryResultSymbol;| $sq| 1| 2n| +|check| echo |$scell| 4| + +-! | +|# Page must have an exception| +| test results for page | TestPage | should contain | 1 right, 0 wrong, 0 ignored, 0 exceptions | +|# echo $cell must be flagged as pass| +| ensure | content contains | !-scell->[4]-!| +| ensure | content contains | !-class="pass">4<-!| + + +!1 Negativ Test Cases + +!2 Symbol has the wrong Type: Passed a String instead of an Array + +!| script | +| given page | TestPage | with content | ${SUT_PATH} !- +!define TEST_SYSTEM {slim} +| import | +| fitnesse.slim.test | + +!|Library| +|EchoScript| + +|script| +|$sstr= | echo |"Hello World!"| +|$scell= | getValuefromQueryResultSymbol;| $sstr| 1| 2n| +|check| echo |$scell| 4| + +-! | +|# Page must have an exception| +| test results for page | TestPage | should contain | __EXCEPTION__:java.lang.ArrayIndexOutOfBoundsException | +|# Cell must be flagged as error| +| ensure | content contains | td class="error">getValuefromQueryResultSymbol | +|# Error must happens in expected function| +| ensure | content contains | at fitnesse.slim.SlimHelperLibrary.getValuefromQueryResultSymbol | +|# Test Summary shows exception| +| ensure | content contains | 0 right, 1 wrong, 0 ignored, 1 exceptions | + + + +!2 Query Result row index is out of range + + +!| script | +| given page | TestPage | with content | ${SUT_PATH} !- +!define TEST_SYSTEM {slim} +| import | +| fitnesse.slim.test | + +!|Library| +|EchoScript| + +!|script| Test Query| 2| +|$sq= | query| +|$scell= | getValuefromQueryResultSymbol;| $sq| 4| 2n| +|check| echo |$scell| 4| + +-! | +|# Page must have an exception| +| test results for page | TestPage | should contain | __EXCEPTION__:java.lang.IndexOutOfBoundsException: Index: 4, Size: 2 | +|# Cell must be flagged as error| +| ensure | content contains | td class="error">getValuefromQueryResultSymbol | +|# Error must happens in expected function| +| ensure | content contains | at fitnesse.slim.SlimHelperLibrary.getValuefromQueryResultSymbol | +|# The comand after the exception is still executed| +| ensure | content contains | !-"fail">expected [4]-!| +|# Test Summary shows exception| +| ensure | content contains | 0 right, 1 wrong, 0 ignored, 1 exceptions | + + +!2 Query Result column name doesn't exists + +!| script | +| given page | TestPage | with content | ${SUT_PATH} !- +!define TEST_SYSTEM {slim} +| import | +| fitnesse.slim.test | + +!|Library| +|EchoScript| + +!|script| Test Query| 2| +|$sq= | query| +|$scell= | getValuefromQueryResultSymbol;| $sq| 1| wrongColumnName| +|check| echo |$scell| 4| + +-! | +|# Page must have an exception| +| test results for page | TestPage | should contain | __EXCEPTION__:java.lang.RuntimeException: No column with name 'wrongColumnName' found in row 1 | +|# Cell must be flagged as error| +| ensure | content contains | td class="error">getValuefromQueryResultSymbol | +|# Error must happens in expected function| +| ensure | content contains | at fitnesse.slim.SlimHelperLibrary.getValuefromQueryResultSymbol | +|# The comand after the exception is still executed| +| ensure | content contains | !-"fail">expected [4]-!| +|# Test Summary shows exception| +| ensure | content contains | 0 right, 1 wrong, 0 ignored, 1 exceptions | + + + +!2 Table result column index out of range +Also after an exception the value of a variable stays in sync between clint and server + +!| script | +| given page | TestPage | with content | ${SUT_PATH} !- +!define TEST_SYSTEM {slim} +| import | +| fitnesse.slim.test | + +!|Library| +|EchoScript| + +!|script| Test Query| 3| +|$scell= | echo | InitialValue| +|$sq= | query| +|$scell= | getValuefromTableResultSymbol;| $sq| 2| 5| +|check| echo |$scell| InitialValue| + +-! | +|# Page must have an exception| +| test results for page | TestPage | should contain | __EXCEPTION__:java.lang.IndexOutOfBoundsException: Index: 5, Size: 2 | +|# Cell must be flagged as error| +| ensure | content contains | td class="error">getValuefromTableResultSymbol | +|# Error must happens in expected function| +| ensure | content contains | at fitnesse.slim.SlimHelperLibrary.getValuefromTableResultSymbol | +|# The comand after the exception is still executed| +| ensure | content contains | !-"pass">InitialValue-!| +|# Test Summary shows exception| +| ensure | content contains | 0 right, 0 wrong, 0 ignored, 1 exceptions | + +!2 Table result row index out of range +Also after an exception the value of a variable stays in sync between clint and server + +!| script | +| given page | TestPage | with content | ${SUT_PATH} !- +!define TEST_SYSTEM {slim} +| import | +| fitnesse.slim.test | + +!|Library| +|EchoScript| + +!|script| Test Query| 3| +|$sq= | query| +|$scell= | getValuefromTableResultSymbol;| $sq| 3| 2| +|check| echo |$scell| 4| + +-! | +|# Page must have an exception| +| test results for page | TestPage | should contain | __EXCEPTION__:java.lang.IndexOutOfBoundsException: Index: 3, Size: 3 | +|# Cell must be flagged as error| +| ensure | content contains | td class="error">getValuefromTableResultSymbol | +|# Error must happens in expected function| +| ensure | content contains | at fitnesse.slim.SlimHelperLibrary.getValuefromTableResultSymbol | +|# The comand after the exception is still executed| +| ensure | content contains | !-"fail">expected [4]-!| +|# Test Summary shows exception| +| ensure | content contains | 0 right, 1 wrong, 0 ignored, 1 exceptions | + diff --git a/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/SlimSymbolManipulationException/properties.xml b/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/SlimSymbolManipulationException/properties.xml new file mode 100644 index 0000000000..8f7b17ceee --- /dev/null +++ b/FitNesseRoot/FitNesse/SuiteAcceptanceTests/SuiteSlimTests/SlimSymbolManipulationException/properties.xml @@ -0,0 +1,15 @@ + + + + + This test has been marked as skip because it works perfect when run manual but makes FitNesse hang when called from ant. + six42 + + + + + + + + + diff --git a/FitNesseRoot/FitNesse/UserGuide/WritingAcceptanceTests/SliM/ScenarioTable/content.txt b/FitNesseRoot/FitNesse/UserGuide/WritingAcceptanceTests/SliM/ScenarioTable/content.txt index 4016e89205..96a00a54b8 100644 --- a/FitNesseRoot/FitNesse/UserGuide/WritingAcceptanceTests/SliM/ScenarioTable/content.txt +++ b/FitNesseRoot/FitNesse/UserGuide/WritingAcceptanceTests/SliM/ScenarioTable/content.txt @@ -53,7 +53,9 @@ If you'd rather you can reference the scenario with parameters so long as you ma 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. +You can also use ''output'' header; i.e. a '?' at the end of the name of a header column. +See [[Scenario Test Suite][.FitNesse.SuiteAcceptanceTests.SuiteSlimTests.ScenarioTestSuite]] for examples how to do this. + 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. diff --git a/FitNesseRoot/FitNesse/UserGuide/WritingAcceptanceTests/SliM/ScenarioTable/properties.xml b/FitNesseRoot/FitNesse/UserGuide/WritingAcceptanceTests/SliM/ScenarioTable/properties.xml index e8c0cc026f..8ad5257deb 100644 --- a/FitNesseRoot/FitNesse/UserGuide/WritingAcceptanceTests/SliM/ScenarioTable/properties.xml +++ b/FitNesseRoot/FitNesse/UserGuide/WritingAcceptanceTests/SliM/ScenarioTable/properties.xml @@ -2,6 +2,7 @@ + six42 diff --git a/FitNesseRoot/FitNesse/UserGuide/WritingAcceptanceTests/SliM/SlimProtocol/content.txt b/FitNesseRoot/FitNesse/UserGuide/WritingAcceptanceTests/SliM/SlimProtocol/content.txt index 022284f909..c78484aa77 100644 --- a/FitNesseRoot/FitNesse/UserGuide/WritingAcceptanceTests/SliM/SlimProtocol/content.txt +++ b/FitNesseRoot/FitNesse/UserGuide/WritingAcceptanceTests/SliM/SlimProtocol/content.txt @@ -84,6 +84,15 @@ That last one was probably puzzling. Symbol values are strings or objects (or n * pushFixture(): pushes the object from the dictionary of created objects named "scriptTableActor" on to the stack of actor objects. Throws an exception if no object exists. * popFixture(): pops an object from the stack of actor objects and adds it to the dictionary of created objects with the name "scriptTableActor". Throws an exception if the stack is empty. + To support symbol assignments in Decision Tables which are implemened with a Script or in Table Tables or Query Tables the following four functions are required in a Library: + * freeSymbol + * cloneSymbol + * getValuefromQueryResultSymbol + * getValuefromTableResultSymbol + + For details see: .FitNesse.SuiteAcceptanceTests.SuiteSlimTests.SlimSymbolManipulation + and .FitNesse.SuiteAcceptanceTests.SuiteSlimTests.SlimSymbolManipulationException + !3 Strings and Lists As we will see, slim views a list as a special kind of string. Therefore functions can take and return lists as well as strings. The lists must be lists of strings, but since a list is a special kind of string, lists of lists of lists of ... are possible. The Slim executor will convert back and forth between these forms as needed. diff --git a/FitNesseRoot/FitNesse/UserGuide/WritingAcceptanceTests/SliM/SlimProtocol/properties.xml b/FitNesseRoot/FitNesse/UserGuide/WritingAcceptanceTests/SliM/SlimProtocol/properties.xml index 72aa2b6a6b..e73a1c3d71 100644 --- a/FitNesseRoot/FitNesse/UserGuide/WritingAcceptanceTests/SliM/SlimProtocol/properties.xml +++ b/FitNesseRoot/FitNesse/UserGuide/WritingAcceptanceTests/SliM/SlimProtocol/properties.xml @@ -2,6 +2,7 @@ true true + six42 true true true diff --git a/src/fitnesse/testsystems/slim/tables/ScenarioTable.java b/src/fitnesse/testsystems/slim/tables/ScenarioTable.java index e248a07d8e..38125c4713 100644 --- a/src/fitnesse/testsystems/slim/tables/ScenarioTable.java +++ b/src/fitnesse/testsystems/slim/tables/ScenarioTable.java @@ -83,17 +83,12 @@ private void getArgumentsForAlternatingName() { private void splitInputAndOutputArguments(String argName) { argName = argName.trim(); if (argName.endsWith("?")) { -// String disgracedArgName = Disgracer.disgraceMethodName(argName.substring( -// 0, argName.length())); String disgracedArgName = Disgracer.disgraceMethodName(argName); outputs.add(disgracedArgName); - //inputs.add(disgracedArgName); } else { String disgracedArgName = Disgracer.disgraceMethodName(argName); inputs.add(disgracedArgName); } - System.out.println("Inputs : " + inputs.toString()); - System.out.println("Outputs: " + outputs.toString()); } private void getArgumentsForParameterizedName() { @@ -102,7 +97,6 @@ private void getArgumentsForParameterizedName() { for (String argument : arguments) { splitInputAndOutputArguments(argument); - //addInput(Disgracer.disgraceMethodName(argument.trim())); } } @@ -285,12 +279,11 @@ private ScenarioExpectation(ScriptTable scriptTable, int row) { public TestResult evaluateExpectation(Object returnValue) { SlimTable parent = scriptTable.getParent(); ExecutionResult testStatus = ((ScenarioTestContext) scriptTable.getTestContext()).getExecutionResult(); - if (outputs.isEmpty()){ - // if the scenario has no output parameters the whole line should be flagged + if (outputs.isEmpty() || testStatus != ExecutionResult.PASS){ + // if the scenario has no output parameters + // or the scenario failed + // then the whole line should be flagged parent.getTable().updateContent(getRow(), new SlimTestResult(testStatus)); - }else{ - // Update the first column in the row which called the scenario with the scenario result - parent.getTable().updateContent(0, getRow(), new SlimTestResult(testStatus)); } return null; }