Search code examples
bddjbehave

JBehave examples table and Date objects


I have a JBehave test which lists some expected results in an ExamplesTable

Then result is :
|name|value|
|foo|2011-05-29|
|bar|baz|

And the object under test is something like:

class A {
    private Date foo; 
    private String bar; 
    /* ... */ 
}

How do I tell JBehave to consider the parameter for foo as a date? I would prefer to implement my own converter.


Solution

  • See the documentation on parameter converters. Of course, if you are taking in an ExampleTable object and calling get on the row, you need to convert it yourself, or reuse an existing converter. Also look at JBEHAVE-398 which I've not tried yet, but might help if you are using JBehave 3.2 or higher.