| Import |
| com.greenpepper.samples.application.calculator |
The RuleForInterpreter is used to express concrete and measurable business rules.
During the execution of the specification, GreenPepper 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 GreenPepper.
- 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
GreenPepper offers a list of useful keywords to support the Business Expert.
| Empty cells |
When a test cell is left blank, GreenPepper only shows the returned value |
| error |
When you expect an error, specify it in the cell to test that particular behavior |
| OGNL |
You can use OGNL expressions as expected test results. |
| rule for |
calculator |
| x |
y |
quotient? |
| 6 |
2 |
|
| 1 |
0 |
error |
| 30 |
3 |
? >= 9 and ? < 12 |
| 30 |
2 |
=30/2 |
Coloring
GreenPepper 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 GreenPepper provides information about the error. |
| GRAY |
If no expected value is specified in a test, the RuleForInterpreter colors the cell in gray. |
Here is an example of cell coloring:
| rule for |
calculator |
| x |
y |
sum? |
product() |
quotient? |
| 10 |
0 |
10 |
0 |
0 |
| 6 |
3 |
9 |
-5 |
|