Dashboard > GreenPepper Examples > Home > Collection of values sample
  GreenPepper Examples Log In View a printable version of the current page.  
  Collection of values sample
Added by admin, last edited by Vincent Tence on Aug 03, 2007  (view change)
Labels: 
(None)

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

GreenPepper offers different kinds of collection interpreters. This example shows the use of interpreters of type collection.

Import
com.greenpepper.samples.application.phonebook

First lets create a collection

do with phone book
insert Paul   Tobin with number (123) 456-7890
insert Henry   Cinq with number (123) 321-7666
insert Steve   Job with number (123) 989-4455

This will create a phone book with three entries.
Before moving on with the example, lets clarify what is happening in the above table.
In this example, the columns with values "insert", a whitespace and "with number" are combined by the interpreter to know which function to execute. The other columns are the values used by the function being executed. So in the case of the second table row, GreenPepper would execute a function called "insertwithnumber" and give it the parameters "Paul", "Tobin" and "(123) 456-7890".
It is important to note that, in this case, the empty column is important for the correct creation of the collection. If the empty column was removed, the values that is intended to be used as a value (the last name in the example above) would be instead considered as part of the function name. The column removal would also offset the next columns so that the function being called would be "insertTobin(123)456-7890" and its values would be "Paul" and "with number".

Using interpreter of type list

A list of interpreter retrieves all entries of the specified object and makes sure that the retrieved list are in the same order as the one specified in the table.

list of Phone book entries
FirstName LastName
Paul Tobin
Steve Job
Henry Cinq

In the example all phone book entries are retrieved. We expect that there are three items in the list in the system under test (SUT).

Using interpreter of type set

In a set of interpreter, we try to match all the items in the rows with those in the SUT collection. The items can be in a different order in the test specification and in the SUT collection.
Missing rows are rows that are in the test specification but not found in the SUT collection.
Surplus rows are rows that are found in the SUT collection but not expected in the test specification.

set of Phone book entries
FirstName LastName
Joe Tagliani
Henry Cinq
Paul Tobin

Using interpreter of type subset

In a subset of interpreter, we assume that all the rows in the test specification are a subset of the rows returned by the SUT collection.
We check that no rows from the specification are missing from the SUT collection. Additional rows can be returned by the SUT.

subset of Phone book entries
FirstName LastName
Joe Tagliani
Henry Cinq
Paul Tobin

Using interpreter of type superset

In a superset of interpreter, we assume that all the rows returned by the SUT must be present in the test specification. Some rows in the test might not be returned by the SUT.

superset of Phone book entries
FirstName LastName
Joe Tagliani
Henry Cinq
Paul Tobin

Site powered by a free Open Source Project / Non-profit License (more) of Confluence - the Enterprise wiki.
Learn more or evaluate Confluence for your organisation.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.4.3 Build:#705 Mar 21, 2007) - Bug/feature request - Contact Administrators