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

Version 1 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.

  • No labels