Have been using Spock a fair bit, and really like the ability to use tables in tests for input/output scenarios.
example from spock docs:
class Math extends Specification {
def "maximum of two numbers"(int a, int b, int c) {
expect:
Math.max(a, b) == c
where:
a | b | c
1 | 3 | 3
7 | 4 | 4
0 | 0 | 0
}
}
I work in the finance industry where we deal with a lot of trading "books".
Would be great to represent those books in tabular form.
So instead of using builders, e.g:
builder.addQuote( 1000000, 1.1220, 1.2230)
.addQuote( 2000000, 1.1219, 1.2233)
.addQuote(10000000, 1.1217, 1.2234)
.addQuote(15000000, 1.1216, 1.2240)
Would be great to use some kind of table:
List<Quote> quotes = new ArrayList<Quote>();
MyUtil.insertInto(quotes).fromTable{
quantity | bid | ask
1000000 | 1.1220 | 1.2230
2000000 | 1.1219 | 1.2233
10000000 | 1.1217 | 1.2234
15000000 | 1.1216 | 1.2240
}
Have seen someone go some of the way to do this here, but the example assigns the results to a general "Row" object.
Would be great to have a utility which writes the row values to a given domain object, using the field names from the first row.