Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Excerpt

Table of Contents
absoluteUrltrue

 

 



Note
titlePlease Note:

The following executable tables are designed with a header row of 2 columns. This is just design. You can create tables with e.g. 3x3 cells.

...

In order to be executable in , the specification must be expressed in a specific form :

rule for
Decision TableCalculator
xysum?
639

The first line of the specification explains that we have particular RULES FOR our Calculator. The calculator receives two numbers and gives back the sum of those two numbers. Once the calculator is developed, we will be able to execute the specification to test the functionality.

...

Once the Calculator is developed, the business expert may think about new examples that he would like to test. The business expert adds another row in the Rule For Decision Table table and executes the test (no coding is needed here).

rule for
Decision TableCalculator
xysum?
639
708

When there is an error,  colors the cell in red.
In the new example, it is clear that the expected value provided by the business expert is not correct. But the error could have been in the system.

...

The business expert wants to improve the Calculator: The Calculator should be able to perform product and quotient of two numbers.
The new rules can be written in a way similar to the "sum" specification. In case of expected errors, the keyword error may be used in order to test those special cases.

rule for
Decision TableCalculator
xysum?product?quotient?
628123
7070error

Rule Validation (

...

Decision Table)

Definition

Panel
bgColor#FFFFFF
titleBGColor#F0F0F0
borderStylesolid
titleDEFINITION
borderStylesolid

The RuleForInterpreter is used to express concrete and measurable business rules.
During the execution of the specification,  compares the values returned by the system under development against the expected values defined by the Business Expert.

  • The first row of the table indicates the set of rules to be tested by .
  • The next row is called the header row and serves to distinguish the given values and the expected values. Given values serve as input to the system, whereas expected values serve as comparison values against values that are actually returned by the system. When a column header ends with special characters ? or (), it denotes an expected value.
  • Finally, the remaining rows capture the examples. They are the executable test rows.

...

 offers a list of useful keywords to support the Business Expert.

Empty cells
When a test cell is left blank, Image Modified only shows the returned value
errorWhen you expect an error, specify it in the cell to test that particular behavior

Coloring

 will visually show the test result by coloring each testing cell: 


Panel
bgColorlightgreen
titleBGColorlightgreen
borderStyledashed
titleGreen
borderStyledashed

 When the expected value matches the returned value, the RuleForInterpreter colors the cell as "right" by coloring it green.

Panel
borderStyle
bgColor#f08080
titleBGColor#f08080
borderStyledashed
titleReddashed

If the values don't match, the RuleForInterpreter colors the cell as "wrong" in red.

Panel
bgColor#f0e68c
titleBGColor#f0e68c
borderStyledashed
titleYELLOWborderStyledashed

If the system encounters an execution error, the cell is colored yellow and  provides information about the error.

Panel
bgColorlightgrey
titleBGColorlightgrey
borderStyledashed
titleGreyborderStyledashed

If no expected value is specified in a test, the RuleForInterpreter colors the cell in gray.

...


Here is an example of cell coloring:

Input Table:

rule for
Decision TableCalculator
 

xysum?product()quotient?
1001000
639-5
 

Output Table:

rule for
Decision TableCalculcator
 

xysum?product()quotient?
100100

0


java.lang.ArithmeticException: / by zero
info.novatec.testit.livingdoc.fixture.calculator.Calculator.quotient(Calculator.java:63)
639Expected:  -5  Received:  182

 


Writing a

...

Decision Table Specification

When do we use the RuleForInterpreter?

...

When a table of rule is executed,  compares the values returned by the system under development against the expected values defined by the Business Expert.

First row: Identification of the

...

Decision Table

In a Rule For Decision Table table, the first row specifies the name of the interpreter and the name of the rules to be tested.
The business expert should be clear in the identification of the set of rules.

  • Example Division : A simple system performing divisions. In that particular case, we could define the set of rules as Division which leads to:

    rule for
    Decision TableDivision
  • Example Mortgage : A Mortgage management system with the following specifications:
    "Whenever the down payment on the property is less than 25% of the sale price, the buyer has to pay a premium for insuring the mortgage. The premium fee amount is 2.5% of the financed amount (which is sale price - down payment)."
    For that particular calculation we could identify the set of rules as:

    rule for
    Decision Tableinsurance premium fee calculation

Second row: the Header

The second row is called the header row and serves to distinguish between the given values and the expected values. Given values serve as inputs to the system, whereas expected values serve as comparison values against values that are actually returned by the system. When a column header ends with special characters ? or (), it denotes an expected value.

  • Example Division : The given values for that example are the dividend and the divisor. The expected value is the quotient.

    rule for
    Decision TableDivision
    dividenddivisorquotient?
  • Example Mortgage : The given values for that example are the sale price and the down payment. The expected value is the premium fee.

    rule for
    Decision Tableinsurance premium fee calculation
    sale pricedown paymentpremium fee?

Third and following rows: Examples

...

Final expression of the Division example

rule for
Decision TableDivision
dividenddivisorquotient?
6.02.03.0
723.5
183.06
1528

Final expression of the Mortgage example

Specification: "Whenever the down payment on the property is less than 25% of the sale price, the buyer has to pay a premium for insuring the mortgage. The premium fee amounts is 2.5% of the financed amount (which is sale price - down payment)."

rule for
Decision Tableinsurance premium fee calculation
sale pricedown paymentpremium fee?
$100,000$15,000$2,125.00
$100,000$30,000$0.00
$100,000$25,000$0.00

When there is no expected value specified in a cell,  provides the value calculated by the system under development. The business expert could use that functionality to facilitate the comprehension of a rule. In this example, the financed amount of mortgage can be evaluated as an intermediate result.

rule for
Decision Tableinsurance premium fee calculation
sale pricedown paymentpremium fee?financed amount?
$100,000$15,000$2,125.00
 

$100,000$30,000$0.00
 

$100,000$25,000$0.00
 

Execution of specifications

...

Panel
borderStyle
bgColor#FFFFFF
titleBGColor#F0F0F0
borderStylesolid
titleDEFINITIONsolid

The collection interpreters are used to express any kind of groups, lists or sets of values.

When a collection interpreter is executed,  compares the list of values expected with the list of values returned by the system under development. The test result depends on the specific collection interpreter selected.

  • As for all other interpreters, the first row of the collection interpreters specifies the name of the interpreter and the name of the collection to be tested.
  • The next row is used to define the name of each attribute related to the members of the collection of data.
  • The following rows are used to specify the set of values to test.

...

Panel
bgColorlightgreen
titleBGColorlightgreen
borderStyledashed
titleGreenborderStyledashed

 As expected, the row is returned by the system under development.

Panel
bgColor#f08080
titleBGColor#f08080
borderStyledashed
titleRedborderStyledashed

A row is missing or in surplus in the list returned by the system under development.

Panel
bgColor#f0e68c
titleBGColor#f0e68c
borderStyledashed
titleYELLOW
borderStyledashed

If the system encounters an execution error, the cell is colored in yellow, and  provides information about the error.

...

 offers four different CollectionInterpreters:

ListOfInterpreterThis interpreter expects to match the content and the order of the list returned by the system under development (SUD) with the expected list defined in the specification.

Image Modified

A is a subset of B
B is a superset of A

SetOfInterpreterThe SetOfInterpreter expects to match only the content of the list returned by the SUD with the expected list defined in the specification. The order of the rows is not important.
SubsetOfInterpreterThe SubsetOfInterpreter verifies that each row defined in the specification exists in the list returned by the SUD. In order to have a successful test, the set of elements listed in the specification should be a subset of the list returned by the SUD.
SupersetOfInterpreterThe SupersetOfInterpreter verifies that each row returned by the SUD exists in the list defined in the specification. In order to have a successful test, the set of elements listed in the specification should be a superset of the list returned by the SUD. This means that the specification may contain rows that are not contained in the SUD.

First row: Identification of the Collection Interpreter

...

  • Example - Provinces of Canada: A simple example would be a system containing the Canadian provinces name and code. In that particular case, we could define the collection as Canada Province Codes :

    list ofCanada Province Codes
  • Example - Phone Book : A phone book application able to manage the first name, last name and the phone number of people. The ListOfInterpreter could be expressed as :

    list of

    phone book entries

Other rows: A set of elements

...

  • Example - Provinces of Canada :

    list ofCanada Province Codes
    NameCode
    ALBERTAAB
    BRITISH COLUMBIAAB
  • Example - Phone Book :

    list ofphone book entries
    FirstNameLastNamePhone Number
    FredFlintstone(123) 456-7890
    BarneyRubble(123) 321-7666
    GreatGazoo(123) 989-4455

Execution of specification

...

Since the SupersetOfInterpreter accepts that the specification may contain rows that are not contained in the SUD,  will not color the rows, which are contained in the specification but not returned by the SUD.

 


Executable specification for the example - Provinces of Canada

list ofCanada Province Codes
NameCode
ALBERTAAB
BRITISH COLUMBIABC
MANITOBAMB
NEW BRUNSWICKNB
NEWFOUNDLAND and LABRADORNL
NOVA SCOTIANS
NUNAVUTNU
ONTARIOON
PRINCE EDWARD ISLANDPE
QUEBECQC
SASKATCHEWANSK
YUKONYT
OTHER PROVINCEOP

Executable specification for the example - Phone Book

Creating the collection of data
We will use the DoWithInterpreter to create our personal phone book.

do with
Workflowphone book
insertFred
 

Flintstonewith number(123) 456-7890
insertBarney
 

Rubblewith number(123) 321-7666
insertGreat
 

Gazoowith number(123) 989-4455

ListOfInterpreter : The requirement list should be the same as the SUD list.

list ofPhone book entries
FirstNameLastName
FredFlintstone
BettyRubble
GreatGazoo
WilmaFlintstone

SetOfInterpreter : The requirement set should be the same as the SUD set.

set ofPhone book entries
FirstNameLastName
FredFlintstone
BettyRubble
GreatGazoo
WilmaFlintstone

SubsetOfInterpreter : The requirement set should be a subset of the SUD set.

subset ofPhone book entries
FirstNameLastName
FredFlintstone
BettyRubble
GreatGazoo
WilmaFlintstone

SupersetOfInterpreter : The requirement set should be a superset of the SUD set.

superset ofPhone book entries
FirstNameLastName
FredFlintstone
BettyRubble
GreatGazoo
WilmaFlintstone
Info

The examples provided in this page are used to explain how to write the fixture for the CollectionInterpreters.

...

Panel
bgColor#FFFFFF
titleBGColor#F0F0F0
titleborderStyleDEFINITIONsolid
borderStyletitlesolidDEFINITION

The DoWithInterpreter is used to express interactions with the system under development that must be performed in a particular order. This form of specification provides information about the business flow.

When a sequence of action is executed,  confirms that each action has successfully been performed.

  • As for all other interpreters, the first row of the DoWithInterpreter specifies the name of the interpreter and the name of the sequence of actions to be tested. What makes the DoWithInterpreter particular is that it only has to be defined once for all the sequences of actions expressed in a page. Obviously, the DoWithInterpreter must be defined before any sequence of actions.
  • The following rows are used to express specific actions.
  • The form of each row of a DoWithInterpreter shall respect the following rules:
    • a row shall begin with a part of the action description,
    • each parameter shall be isolated in a cell,
    • each parameter shall be separated by parts of the action description.
  • An action description can be left blank in order to separate two parameters.
  • The DoWithInterpreter provides a minimum of keyword used to define a specific action.
  • The DoWithInterpreter may also be expressed in Bullet List form or Number List form.

...

 offers a list of useful keywords to support the Business Expert. Those keywords are placed at the beginning of an action row.

AcceptConfirm that the action has been executed by the system under development.
CheckVerify the specified expected value with the value returned by the system under development
RejectThe action should not be performed by the system under development (expected errors).
DisplayPrint the value returned by the system under development.

coloring

 will visually show the test result by coloring each testing cell:

Panel
bgColorlightgreen
titleBGColorlightgreen
borderStyledashed
titleGreenborderStyledashed

When the action has been executed successfully,  colors the cell(s) in green.

Panel
bgColor#f08080
titleBGColor#f08080
borderStyledashed
titleRed
borderStyledashed

If the action execution has failed,  colors the cell(s) in red.

Panel
borderStyle
bgColor#f0e68c
titleBGColor#f0e68c
borderStyledashed
titleYELLOWdashed

If the system encounters an execution error, the cell is colored yellow and  provides information about the error.

Panel
bgColorlightgrey
titleBGColorlightgrey
borderStyledashed
titleGreyborderStyledashed

When the action has been executed successfully,  will display the returned value in gray.

Standard form (without keyword)Only the Action description will be colored.
AcceptOnly the cell containing the keyword Accept will be colored.
Check
The cell containing the expected value will be colored. In the case of a failure, Image Modified will show the expected and the returned values.
RejectOnly the cell containing the keyword Reject will be colored.
DisplayA new cell at the end of the row will be colored containing the returned value.

Writing a

...

Workflow specification

When do we use the DoWithInterpreter

...

When a sequence of action is executed,  confirms that each action has successfully been performed.

First row: Identification of the

...

Workflow

As for all other interpreters, the first row of the DoWithInterpreter specifies the name of the interpreter and the name of the sequence of actions to be tested. What makes the DoWithInterpreter particular is that it only has to be defined once for all the sequences of actions expressed in a page. Obviously, the DoWithInterpreter must be defined before any sequence of actions.

...

So the first line could be expressed as

do with
Workflowbank account management

or more simply as

do with
Workflowbank

Following rows: Actions & Verifications

...

Info

The form of each row of a DoWithInterpreter must follow these rules:

  • a row begins with a part of the action description.
  • each parameter is isolated in a cell
  • each parameter is separated by parts of the action description.
  • an action description can be blank

More visually:

Action description part 1parameter 1Action description part 2parameter 2Action description part 3Parameter 3...

Example: In our bank example, the first action would be to create a bank account.

If we want to take the account number as a parameter, we would have:

open checking account12345-67890

But, if we want to consider the type of account, the account number, the owner first name and last name as parameters, we would have:

opencheckingaccount12345-67890under the name ofSpongebob
 

Squarepants

Example: Verify the balance of an account

To verify the success of a particular action, we write the keyword "Check" prior to the first part of the action description.
In our example, there would be two parameters: the account number and the amount of balance.

checkthat balance of account12345-67890is$0.00

Final expression of our example

do with
Workflowbank

Our first business rule says that a new account should have a balance of 0.00 dollars.

opencheckingaccount12345-67890under the name ofSpongebob
 

Squarepants
checkthat balance of account12345-67890is$0.00

Our next rule says that the bank should not take any fees when we deposit money in our account.

deposit$100.00in account12345-67890
checkthat balance of account12345-67890is$100.00

The following rule says that a customer should be able to withdraw funds, if the balance of his account is sufficient.

withdraw$50.00from account12345-67890
checkthat balance of account12345-67890is$50.00
rejectwithdraw$75.00from account12345-67890
checkthat balance of account12345-67890is$50.00
acceptwithdraw$25.00from account12345-67890

Execution of specification

...

Info

The examples provided in this page are used to explain how to write the fixture for the DoWithInterpreter.

Scenario specification

Definition

Panel
bgColor#FFFFFF
titleBGColor#F0F0F0
titleDEFINITION
borderStylesolid

The ScenarioInterpreter is used to express interactions with the system under development that must be performed in a particular order. This form of specification provides information about the business flow.

When a sequence of action is executed, Image Removed confirms that each action has successfully been performed.

ScenarioIdentification of the set of rule
Action 1
Action 2
...
Action i
  • As for all other interpreters, the first row of the ScenarioInterpreter specifies the name of the interpreter and the name of the sequence of actions to be tested. What makes the ScenarioInterpreter particular is that it only has to be defined once for all the sequences of actions expressed in a page. Obviously, the ScenarioInterpreter must be define before any sequence of actions.
  • The ScenarioInterpreter may also be expressed in Bullet List form or Number List form.

 

Coloring

Image Removed will visually show the test result by coloring a complete row or words inside the row:

Panel
bgColorlightgreen
titleBGColorlightgreen
titleGreen
borderStyledashed

When the action has been executed successfully, Image Removed colors the row or words inside the row in green.

Panel
bgColor#f08080
titleBGColor#f08080
titleRed
borderStyledashed

If the action execution has failed, Image Removed colors the the row or words inside the row in red.

Panel
bgColor#f0e68c
titleBGColor#f0e68c
titleYELLOW
borderStyledashed

If the system encounters an execution error, the row is colored yellow and Image Removed provides information about the error.

Panel
bgColorlightgrey
titleBGColorlightgrey
titleGrey
borderStyledashed

When the action has been executed successfully, Image Removed will display the returned value in gray.

Writing a Scenario specification

When do we use the ScenarioInterpreter

The ScenarioInterpreter is used to express interactions with the system under development that must be performed in a particular order. This form of specification provides information about the business flow.

When a sequence of action is executed, Image Removed confirms that each action has successfully been performed.

First row: Identification of the Scenario

As for all other interpreters, the first row of the ScenarioInterpreter specifies the name of the interpreter and the name of the sequence of actions to be tested. What makes the ScenarioInterpreter particular is that it only has to be defined once for all the sequences of actions expressed in a page. Obviously, the ScenarioInterpreter must be defined before any sequence of actions.

Example of a bank Account management system

Example context :  The system under development must be able to manage two different types of bank account. The system should allow to execute the usual transactions within an account.

So the first line could be expressed as

scenariobank account management

or more simply as

scenariobank

Following rows: Actions & Verifications

The second and following rows are used to express specific actions or verifications. The business expert should express the action in human readable format rather than using computer like language.

Info

With this interpreter, only 1 cell is required to express the action (in comparison to the DoWithInterpreter).

Example: In our bank example, the first action would be to create a bank account .

If we want to take the account number as a parameter, we would have:

open checking account 12345-67890

But, if we want to consider the type of account, the account number, the owner first name and last name as parameters, we would have:

open checking account 12345-67890 under the name of Spongebob Squarepants

Example: Verify the balance of an account

In our example, there would be two parameters: the account number and the amount of balance.

verify that balance of account 12345-67890 is $0.00

Final expression of our example

scenariobank

Our first business rule says that a new account should have a balance of 0.00 dollars.

open checking account 12345-67890 under the name of Spongebob Squarepants
verify that balance of account 12345-67890 is $0.00

Our next rule says that the bank should not take any fees when we deposit money in our account.

deposit $100.00 in account 12345-67890
verify that balance of account 12345-67890 is $100.00

The following rule says that a customer should be able to withdraw funds if the balance of his account is sufficient.

...

write the fixture for the DoWithInterpreter.


Execution of specification

Based on those executable specifications, the developers are now ready to code the functionality and the fixture (the fixture is the link between the system under development and the executable specification). Once this is done, the specification can be executed by clicking on the Execute button on the top of the page.

...

6. Context definition (Setup)

Definition

Panel
bgColor#FFFFFF
titleBGColor#F0F0F0
borderStylesolid
titleDEFINITIONborderStylesolid

The SetUpInterpreter is used to simplify the creation of a particular state for the system under development. Once the state is created, we can focus on the business process to test.

When a setup table is executed,  enters data in the system under development to create the desired state.

  • The first row of the table indicates the name of the interpreter and the name of the desired state.
  • The second row is called the header row and serves to identify the data to be inserted in the system under development.
  • Finally, the remaining rows capture the data to be inserted.

Coloring

 will visually show the test result by coloring each testing cell:

Panel
bgColorlightgreen
titleBGColorlightgreen
borderStyledashed
titleGreenborderStyledashed

When the insertion has been executed successfully,  adds a green cell at the end of the data row with the word entered.

Panel
bgColor#f08080
titleBGColor#f08080
borderStyledashed
titleRed
borderStyledashed

If the insertion has failed because the values specified does not respect a business rule,  adds a red cell at the end of the row with the word not entered.

Panel
borderStyle
bgColor#f0e68c
titleBGColor#f0e68c
borderStyledashed
titleYELLOWdashed

If the insertion has failed because a specified value generates an error,  colors the cell of the data in error yellow and provides information about the error.
If the system encounters an error not related to a specific data,  adds a yellow cell at the end of the data row and provides information about the error.

...

As for all other interpreters, the first row of the setup table specifies the name of the interpreter and the name of the desired state.

Example of a bank Account management system

Example context : A customer should be allowed to transfer money from his or her accounts.

In order to create examples that would test this particular business rule, we need to create a set of customer. The first line of our setup table could be expressed as

setupa group of customers

Second row: the Header

The second row is called the header row and serves to identify the data to be inserted in the system under development.

Example: In our bank example, the header row could take the following form.

setupa group of customers
typenumberfirst namelast namebalance

Following rows: Data

The remaining rows capture the data, which is meant to be inserted. They are the executable rows.

Final expression of our example

setupa group of customers
typenumberfirst namelast namebalance
checking11111-11111    FredFlintstone$250.00
savings22222-22222    FredFlintstone$10 000.00
savings44444-44444    WilmaFlintstone$10 000.00
checking44444-44444    BarneyRubble$999.54
checking55555-55555    GreatGazooabc

From that point, we can now used those accounts to specify examples that define a business rule.

do with
Workflowbank

Transfer from a savings account to a checking account of the same customer

acceptTransfer$1 000.00from account22222-22222    to account11111-11111    
checkthat balance of account11111-11111    is$1 250.00
checkthat balance of account22222-22222    is$9 000.00

Execution of specification

...

Info

The examples provided in this page are used to explain how to write the fixture for the SetupInterpreter.

Advanced

...

Workflow - Table, Bullet List or Number List example

 supports the expression of rules in table format, bullet list format or number list format. The following examples are equivalent and will yield the same results when executed.

It is important to note that the table and bullet list examples are not executable, since the import info.novatec.testit.livingdoc.samples.fixture.bank and do with Workflow bank rules cannot be specified twice in the same page. Even though it is possible to change between the two methods in the same page, you must keep in mind that the tests are executed in the same system under development. So it is not necessary to re-specify the same rule in the page.

Table

import
info.novatec.testit.livingdoc.samples.application.bank
do with
Workflowbank
opencheckingaccount12345-67890under the name ofSpongebob
 

Squarepants
checkthat balance of account12345-67890is$0.00
deposit$100.00in account12345-67890
checkthat balance of account12345-67890is$100.00

Bullet List

  • import
  • info.novatec.testit.livingdoc.samples.application.bank

 


  • do withWorkflow bank
  • open checking account 12345-67890 under the name of Spongebob _Squarepants
  • deposit $100.00 in account 12345-67890
  • check that balance of account 12345-67890 is $100.00

...

  • import
  • info.novatec.testit.livingdoc.samples.application.bank


  1. Workflow 

...

  1. do with bank
  2. open checking account 12345-67890 under the name of Spongebob _Squarepants
  3. deposit $100.00 in account 12345-67890
  4. check that balance of account 12345-67890 is $100.00

...

 has an extension to supports OGNL expressions. Here are some examples, using the Calculator system:

< , <= , > , >= , and , or
Image Modified supports these simple mathematical expressions. Use the question mark to specify the position of the value returned by the system. For example, if the expected value should be greater than 15, you would write "? > 15" in the cell.
+ , - , / , *
Image Modified performs simple operations as a resulting expression. To specify you want to evaluate those operations prior to the comparison, insert an equal sign at the beginning of the operation (ex: =4+1-3).
rule for
Decision Tablecalculator
xysum?product?quotient?
628123
7070error
405090? > 100
 

4-5? <= 0-20? <= 0
33? < 1 or ? > 4? >= 9 and ? < 12"1"
42=4+2-0=2*4=4/2

To use this extension, you need to specify the fixture factory as info.novatec.testit.livingdoc.extensions.ognl.OgnlSupport and add the livingdoc-extensions-ognl-x.x.jar and ognl-x.x.x.jar to the classpath of the SUT.

...

To avoid undesired interpretation of forms, we can use the Information tags.
This tag will force  to skip all forms between the Begin Info and End Info tags.

Here is an example:

Begin Info
This tableshouldn't beinterpreted
  • This bullet list
  • shouldn't be
  • interpreted either
End Info

We won't see any coloration of the above table or bullet list after execution of this document.

 will restart the interpretation of the document from from this point.

Rule for
Decision TableCalculator
xysum?
123
Info
titleUseful Information

If the End Info tag is omitted all the body content of the document after the Begin Info tag, will be skipped.

...

Test using the Table form.

Comment
My tableto skip

We won't see any coloration of the above table or bullet list after execution of this document.

 will restart the interpretation of the document from from this point.

Rule for
Decision TableCalculator
xysum?
123