jtanistra / spock

Automatically exported from code.google.com/p/spock
0 stars 0 forks source link

Allow multiple where-blocks to enhance readability options #321

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
See example gist for illustration of a multiple where block use case: 
https://gist.github.com/cathalking/76fd9ad59a38b6910f03

Discussed at: https://groups.google.com/forum/#!topic/spockframework/yQPPjpf9spE

The specific usage I have in mind for this enhancement is related to:
(a) Enhancing readability of especially "wide" where blocks e.g. imagine my 
example where block below, but with another few columns added. It will quickly 
disappear off the screen. By allowing multiple where blocks

(b) Supporting the notion of having separate where "input" and "expectation" 
blocks. Again primarily to enhance readability when both the number of inputs 
and number of expected values is high. Or simply an extra option rather than 
using double pipe || (which is an elegant feature for small blocks)

(c) Gherkin/Cucumber supports the notion of separate data tables e.g one for 
Given, one for When. Which to my mind is a good and useful thing. But then 
AFAIK you are forced to process the entire table in a single pass. I'm not so 
keen on that. Spock thankfully "feeds" the table/where-block in row-by-row. 
Adding additional where blocks would emulate the separate data table feature 
whilst maintaining the desired row-by-row flow.

where: 'Login inputs + Expected Login greetings are:'
login               | password ||   expectedFullName    | expectedLastSeen  | 
expectedRepPoints
'ra...@email.com'   | '123'    ||   'Ralph Malph'       | '20130619'        | '15'
'pot...@email.com'  | '234'    ||   'Potsie Webber'     | '20130617'        | '19'
'ric...@email.org'  | '456'    ||   'Richie Cunningham' | '20130613'        | '21'

Proposed multiple where block layout:
// With a "multiple" *where* block approach the single block is essentially 
broken up (an arbitrary number of times 
//  where: 'Login inputs'
//  login               | password
//  'ra...@email.com'   | '123'
//  'pot...@email.com'      | '234'
//  'ric...@email.org'  | '456'
//
//  where: 'Expected Login greetings'
//  expectedFullName    | expectedLastSeen  | expectedRepPoints
//  'Ralph Malph'       | '20130619'        | '15'
//  'Potsie Webber'     | '20130617'        | '19'
//  'Richie Cunningham' | '20130613'        | '21'

Original issue reported on code.google.com by cathalki...@gmail.com on 14 Jul 2013 at 8:07