How does Spock recognize that it's seeing a data table?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How does Spock recognize that it's seeing a data table?

KARR, DAVID
The way Spock uses data tables is truly amazing, but like other examples of Groovy-based magic, I'm left wondering "how the heck does it do that?"  Most importantly, how does Spock recognize that a data table is present?  If I only ever used tables that looked exactly like the examples I've seen, I'm sure I'd never be surprised, but I wonder what exact syntax markers it looks for, in case there are syntax variations that might seem reasonable, but would cause Spock to not recognize the presence of a data table.

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/spockframework.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How does Spock recognize that it's seeing a data table?

Patrick van Dissel
Hey Karr,

Spock does this with the Groovy AST transformations support as
documented in the groovy docs at:
-
http://docs.groovy-lang.org/docs/latest/html/documentation/#developing-ast-xforms

In the Spock code, this starts by the class:
- org.spockframework.compiler.SpockTransform
  as configured in

spock-core/src/main/resources/META-INF/services/org.codehaus.groovy.transform.ASTTransformation
- and the where blocks are rewritten via AST transformations from:
  org.spockframework.compiler.WhereBlockRewriter

So if you start from:
- org.spockframework.compiler.SpockTransform
you can walk through the code to get all the details.

The test for specificly the DataTables seems to be:
-
spock-specs/src/test/groovy/org/spockframework/smoke/parameterization/DataTables.groovy

Atleast, this is what I learned from the code :)
Hopefully it gives you a few handlebars to work with.

/Patrick

On 04/18/2015 12:02 AM, KARR, DAVID wrote:
> The way Spock uses data tables is truly amazing, but like other examples of Groovy-based magic, I'm left wondering "how the heck does it do that?"  Most importantly, how does Spock recognize that a data table is present?  If I only ever used tables that looked exactly like the examples I've seen, I'm sure I'd never be surprised, but I wonder what exact syntax markers it looks for, in case there are syntax variations that might seem reasonable, but would cause Spock to not recognize the presence of a data table.
>

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/spockframework.
For more options, visit https://groups.google.com/d/optout.
Loading...