[ 
http://jira.codehaus.org/browse/JBEHAVE-398?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=248727#action_248727
 ] 

Daniel Godfrey commented on JBEHAVE-398:
----------------------------------------

I'm mainly using the tables to set up a database and then to import data. The 
defaults allows me to specify values in java, so the stories then don't need to 
contain the data if it's not relevant to the test, but lets me reuse the same 
steps.

So (rubbish example) given a database table that needs a name and age, I can 
have the following line in my @Given step:
{noformat}dao.addUser(record.value("Name"), record.valueAs("Age", 
Integer.class, "19"){noformat}

Then in 1 scenario/story where age is irrelevant I can simply add

{noformat}
When new user added:
  |Name|
  |Dan |
{noformat} 

Then in a different scenario where the age is relevant to the test, I can put
{noformat}
When new user added:
  |Name|Age|
  |Dan |32 |
  |Mark|21 |
{noformat}

The reason for the ExamplesTable#withDefaults(Record) method is it make this 
easy to do in a scenario:
{noformat}
Given user defaults:
  |Age|
  |22 |

When new user addded:
  |Name|
  |Dan |
{noformat} 

This isn't my actual domain, It's trade settlement/confirmation, so there's 
lots of data that's required for each record, most of which is pretty 
irrelevant for the current test, so this allows the tests to focus on what's 
important.

I can add some examples to the Trader example in JBehave if you want?

I'm not convinced myself about the Row -> Record rename either, just convinced 
that Row is the wrong name as they're more useful than simply as Rows. I've 
just written a ParamaterConverter that will covert "key:value\nkey2:value2" 
into a Record and I've been considering using them to read the columns of a 
table, so you can have row/column headers. One idea that crossed my mind was to 
make ConvertingRecord extend Map<String, String>, and change 
ExamplesTable#getRow to return ConvertingRecord (renamed to something sensible 
like ConvertingMap) rather than Map<String, String>. Haven't really thought 
about it in detail, IE backwards compatibility implications, etc.

> Provide conversion of table value
> ---------------------------------
>
>                 Key: JBEHAVE-398
>                 URL: http://jira.codehaus.org/browse/JBEHAVE-398
>             Project: JBehave
>          Issue Type: Improvement
>          Components: Core
>    Affects Versions: 3.1.2
>            Reporter: Daniel Godfrey
>            Assignee: Mauro Talevi
>             Fix For: 3.2
>
>
> Currently to convert into a List<SomeType> it's necessary to register a 
> custom ParameterConverter. By default it already provides the ability to 
> convert into List<String> and List<subtype of Number>, but this should be 
> extended to support all instances of List<T> as it will reduce the duplicate 
> code necessary.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to