Dashboard > GreenPepperOpen > ... > Writing executable specifications > Writing my first Executable Specification
  GreenPepperOpen Log In View a printable version of the current page.  
  Writing my first Executable Specification
Added by Louis Thibault, last edited by Laurent Cobos on Feb 12, 2007  (view change)
Labels: 
(None)

 GreenPepperAnonymous access is denied. You must log in to use GreenPepper.

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 GreenPepper, the specification must be expressed in a specific form :

Import
com.greenpepper.samples.application.calculator
rule for Calculator
x y sum?
6 3 9

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, GreenPepper 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 GreenPepper that a test must be performed.

In that particular example, GreenPepper 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 GreenPepper. 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 for Calculator
x y sum?
6 3 9
7 0 8

When there is an error, GreenPepper 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.

Begin Info

The business expert should always be consulted before any changes are made in the executable specifications.

End Info

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 for Calculator
x y sum? product? quotient?
6 2 8 12 3
7 0 7 0 error
DEMONSTRATION LICENSE - This Confluence site is for demonstration purposes only. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.4.3 Build:#705 Mar 21, 2007) - Bug/feature request - Contact Administrators