Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

1. Writing my first executable specification

Writing an executable specification for a Calculator program

Consider your customer wants to create a calculator.

The business expert on Calculators explains to the developer the rules for calculation. The first specification is: The calculator should be able to add two numbers. To support the specification, the business expert also provide an example: 6 + 3 = 9.

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

rule forCalculator
xysum?
639

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

Execute the specification

If you hit the Execute button on the top of the page, you will get the result of your test.

How it works?

Once you click on the Execution button,  calls the actual software containing the code for the Calculator. It sends the parameters x (equal to 6) and y (equal to 3) to the Calculator to obtain the resulting sum of those two numbers. The "?" symbol next to the word "sum" is a key-sign that indicates to  that a test must be performed.

In that particular example,  will query the calculator application and compare the value returned by the system with the value specified by the business expert (in the "sum?" column). Since the result returned by the system is the same as the expected result, the cell is colored in green by . The business expert is now confident that the Calculator is able to add two numbers.

Adding another example

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

rule forCalculator
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 should always be consulted before any changes are made in the executable specifications

Adding new specifications to our Calculator

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 an expected errors, the keyword error may be used in order to test those special cases.

rule forCalculator
xysum?product?quotient?
628123
7070error

2. Rule Validation (Rule For)

Definition

DEFINITION

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 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.
  • Finally, the remaining rows capture the examples. They are the executable test rows

Specific Keywords for expected values

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

Empty cellsWhen a test cell is left blank,  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:

 

Green

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

Red

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

YELLOW

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

Grey

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

 

Here is an example of cell coloring:

rule forcalculator
xysum?product()quotient?
1001000
639-5 

Writing a Rule For Specification

When do we use the RuleForInterpreter?

The RuleForInterpreter is used to express concrete and measurable business rules. The business rules are often related to all kind of calculations.

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 Rule For

In a Rule For 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 forDivision
  • 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 forinsurance 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 forDivision
    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 forinsurance premium fee calculation
    sale pricedown paymentpremium fee?

Third and following rows: Examples

The remaining rows capture the examples. They are the executable test rows.

Final expression of the Division example

rule forDivision
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 forinsurance 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 forinsurance 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

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.

During execution,  colors only the cells of the column "expected values".  will color the cell green if the returned value equals the expected value. If the returned value is not the same,  will color the cell red and will show the expected and the returned values. Finally, if an expected value is left blank by the business expert,  colors the cell in gray to signify that no test was performed and shows the returned value.

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

3. List Validation (List of, Set of, Superset of, Subset of)

Definition

DEFINITION

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.

Specific keywords

None

Colouring

 will visually indicate the test result by colouring the rows:

Green

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

Red

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

YELLOW

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

Particular behaviour for the list of interpreters:
Since the ListOfInterpreter expects to match exactly the expected list and the list returned by the SUD,  compares each cell of the table separately. If the expected value is different from the returned value,  colours the cell in red and provide the two values.

Particular behaviour for the superset of interpreters:
Since the SupersetOfInterpreter accepts that the specification may contain rows that are not contained in the SUD,  will not colour the rows contained in the specification but not returned by the SUD.

Writing a List specification

When do we use the CollectionInterpreters

The CollectionInterpreters are used to express any kind of group, list or set of values.

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

 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.

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

As for all other interpreters, the first row of any CollectionInterpreter specifies the name of the interpreter and the name of the collection to be tested.

  • 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 express as

    list of

    phone book entries

Other rows: A set of elements

From the third row, we specify the set of values to test.

  • 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

Once the developers have coded the functionality and the fixture(the fixture is the link between the system under development and the executable specification), the specification can be executed by clicking on the Execute button on the top of the page.

During execution,  will color the rows in green if the rows are in the list of elements returned by the SUD as expected in the specification.
If a row is missing or in surplus in the list returned by the SUD, then  will color the entire row in red and specify if the row is missing or in surplus.

Notes

If  specify that a row is missing, it means that the row is not in the list of elements provided by the system under development as it should be.
If  specify that a row is in surplus, it means that the row is in the list of elements provided by the system under development but it should not be.

Since the ListOfInterpreter expects to match exactly the list expected and the list returned by the SUD,  compare each cell of the table separately. If the expected value is different from the returned value,  color the cell in red and provide the two values.

Since the SupersetOfInterpreter accept that the specification may contains rows that are not contained in the SUD,  will not color the rows 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 withphone 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

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

  • No labels