| Import |
| com.greenpepper.samples.application.phonebook |
When do we use the CollectionInterpreters
The CollectionInterpreters are used to express any kind of group, list or set of values.
When a CollectionInterpreters is executed, GreenPepper compares the list of expected values with the list of values returned by the system under development. The test result depends on the specific CollectionInterpreters selected.
GreenPepper offers four different CollectionInterpreters:
| ListOfInterpreter |
This interpreter expects to match the content and the order of the list returned by the system under development (SUD) with the expected list defined in the specification. |
| SetOfInterpreter |
The SetOfInterpreter expects to match only the content of the list returned by the SUD with the expected list defined in the specification. The order of the rows is not important. |
| SubsetOfInterpreter |
The SubsetOfInterpreter verifies that each row defined in the specification exists in the list returned by the SUD. In order to have a successful test, the set of elements listed in the specification should be a subset of the list returned by the SUD. |
| SupersetOfInterpreter |
The SupersetOfInterpreter verifies that each row returned by the SUD exists in the list defined in the specification. In order to have a successful test, the set of elements listed in the specification should be a superset of the list returned by the SUD. This means that the specification may contain rows that are not contained in the SUD. |
|
A is a subset of B
B is a superset of A
|
First row: Identification of the Collection Interpreter
As for all other interpreters, the first row of any CollectionInterpreter specifies the name of the interpreter and the name of the collection to be tested.
- Example - Provinces of Canada: A simple example would be a system containing the Canadian provinces name and code. In that particular case, we could define the collection as Canada Province Codes :
| list of |
Canada Province Codes |
- Example - Phone Book : A phone book application able to manage the first name, last name and the phone number of people. The ListOfInterpreter could be express as
| list of |
phone book entries |
The second row is used to define the name of each attribute related to the members of the collection of data.
- Example - Provinces of Canada: The attributes for that example are the name and the code.
| list of |
Canada Province Codes |
| Name |
Code |
- Example - Phone Book : The attributes for that example are the first name, the last name and the phone number.
| list of |
phone book entries |
| FirstName |
LastName |
Phone Number |
Other rows: A set of elements
From the third row, we specify the set of values to test.
- Example - Provinces of Canada :
| list of |
Canada Province Codes |
| Name |
Code |
| ALBERTA |
AB |
| BRITISH COLUMBIA |
AB |
- Example - Phone Book :
| list of |
phone book entries |
| FirstName |
LastName |
Phone Number |
| Fred |
Flintstone |
(123) 456-7890 |
| Barney |
Rubble |
(123) 321-7666 |
| Great |
Gazoo |
(123) 989-4455 |
Execution of specification
Once the developers have coded the functionality and the fixture (the fixture is the link between the system under development and the executable specification), the specification can be executed by clicking on the Execute button on the top of the page.
During execution, GreenPepper will color the rows in green if the rows are in the list of elements returned by the SUD as expected in the specification.
If a row is missing or in surplus in the list returned by the SUD, then GreenPepper will color the entire row in red and specify if the row is missing or in surplus.
 | Notes
If GreenPepper specify that a row is missing, it means that the row is not in the list of elements provided by the system under development as it should be.
If GreenPepper specify that a row is in surplus, it means that the row is in the list of elements provided by the system under development but it should not be. |
Since the ListOfInterpreter expects to match exactly the list expected and the list returned by the SUD, GreenPepper compare each cell of the table separately. If the expected value is different from the returned value, GreenPepper color the cell in red and provide the two values.
Since the SupersetOfInterpreter accept that the specification may contains rows that are not contained in the SUD, GreenPepper will not color the rows in the specification but not returned by the SUD.
Executable specification for the example - Provinces of Canada
| list of |
Canada Province Codes |
| Name |
Code |
| ALBERTA |
AB |
| BRITISH COLUMBIA |
BC |
| MANITOBA |
MB |
| NEW BRUNSWICK |
NB |
| NEWFOUNDLAND and LABRADOR |
NL |
| NOVA SCOTIA |
NS |
| NUNAVUT |
NU |
| ONTARIO |
ON |
| PRINCE EDWARD ISLAND |
PE |
| QUEBEC |
QC |
| SASKATCHEWAN |
SK |
| YUKON |
YT |
| OTHER PROVINCE |
OP |
Executable specification for the example - Phone Book
Creating the collection of data
We will use the DoWithInterpreter to create our personal phone book.
| do with |
phone book |
| insert |
Fred |
|
Flintstone |
with number |
(123) 456-7890 |
| insert |
Barney |
|
Rubble |
with number |
(123) 321-7666 |
| insert |
Great |
|
Gazoo |
with number |
(123) 989-4455 |
ListOfInterpreter : The requirement list should be the same as the SUD list.
| list of |
Phone book entries |
| FirstName |
LastName |
| Fred |
Flintstone |
| Betty |
Rubble |
| Great |
Gazoo |
| Wilma |
Flintstone |
SetOfInterpreter : The requirement set should be the same as the SUD set.
| set of |
Phone book entries |
| FirstName |
LastName |
| Fred |
Flintstone |
| Betty |
Rubble |
| Great |
Gazoo |
| Wilma |
Flintstone |
SubsetOfInterpreter : The requirement set should be a subset of the SUD set.
| subset of |
Phone book entries |
| FirstName |
LastName |
| Fred |
Flintstone |
| Betty |
Rubble |
| Great |
Gazoo |
| Wilma |
Flintstone |
SupersetOfInterpreter : The requirement set should be a superset of the SUD set.
| superset of |
Phone book entries |
| FirstName |
LastName |
| Fred |
Flintstone |
| Betty |
Rubble |
| Great |
Gazoo |
| Wilma |
Flintstone |