Testing a Table of Rules on a System
In this example we're planning to write a calculator executable specification. You can find some basic rules in the first executable specifications page. We will use the Rule For formalism to define the business rules of the basic calculator.
We need to specify the package in which our calculator fixture is coded. Once the execution is started, GreenPepper searches the fixtures name in the package specified in the import tables.
| import |
| com.greenpepper.samples.application.calculator |
In a Rule For formalism, the first row specifies the name of the interpreter
and the name of the fixture.
The second row specifies the input parameter names and tests we want to execute.
The remaining rows indicate values for each input parameter and the expected result from the specified tests. In the last row, you can see how expected validation errors are specified.
You are now ready to execute the tests.
In last row, we specify that the product of 7 and 0 should be 5 (column product?). The cell is now colored in red and we see that there is an error since the product of 7 and 0 is 0, not 5. All the other cells are colored in green since the expected values match the returned values.
| rule for |
calculator |
| x |
y |
sum? |
product? |
quotient? |
| 6 |
2 |
8 |
12 |
3 |
| 7 |
0 |
7 |
0 |
error |
You can also read a description on Writing fixtures for Rule Tables