...
Even though one of the objectives of GreenPepper is to create a common language between the business experts and the development team, there will always be a certain degree of difference between the natural language and the programing language. Hence comes the reason for having fixtures. Fixtures are the glue between the business expert examples and the software being developed. When running the table, GreenPepper uses a fixture to mediate between the example expressed in the table and the system under test.
...
Note |
---|
When using the humanized version of fixture naming, you must use Import Tables. Explicit package won't work ex: |list of | com.xyz.stuff.the fixture name| |
...
Suffix example | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
and
will both match
|
Constructor
A fixture can receive parameters during it's construction. You must have a public constructor that matches the numbers of parameters.
When no parameters are specified in the example, the fixture class must have a public constructor without parameters.
Empty constructor example | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
An example with two parameters | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Rule validation (Rule For)
Definition
Definition |
---|
The RuleForInterpreter is used to express concrete and measurable business rules.
|
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 |
Coloring
GreenPepper will visually show the test result by coloring each testing cell:
Panel | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
When the expected value matches the returned value, the RuleForInterpreter colors the cell as "right" by coloring it green. |
Panel | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
If the values don't match, the RuleForInterpreter colors the cell as "wrong" in red. |
Panel | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
If the system encounters an execution error, the cell is colored yellow and GreenPepper provides information about the error. |
Panel | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
If no expected value is specified in a test, the RuleForInterpreter colors the cell in gray. |
Here is an example of cell coloring:
Input Table:
rule for | calculator | |||
---|---|---|---|---|
x | y | sum? | product() | quotient? |
10 | 0 | 10 | 0 | 0 |
6 | 3 | 9 | -5 |
Output Table:
rule for | calculcator | |||
---|---|---|---|---|
x | y | sum? | product() | quotient? |
10 | 0 | 10 | 0 | 0 java.lang.ArithmeticException: / by zero |
6 | 3 | 9 | Expected: -5 Received: 18 | 2 |
Writing fixtures for Rule tables
As we've seen in Rule For definition, a table of rules is used to express business rules of the application under development.
A fixture for a table of rules defines how the specific given and expected columns of a rule table are mapped to the system under development.
This page shows the fixture code that supports the examples introduced in the Writing a Rule For specification documentation.
List Validation (List of, Set of, Superset of, Subset of)
...