Export to GitHub

spock - issue #387

Where block parameters should be able to reference each other


Posted on Feb 11, 2015 by Happy Panda

It would be nice if parameters defined with << could reference previous definitions. Then one could do things like this to make one's tests more robust to refactoring:

where:
    IDENTIFIER = 'fooId'
    snippet << ["""<label for="${IDENTIFIER}"/><input type="text" id="${IDENTIFIER}" />"""]

However, this is not currently possible:

  • Parameters defined with = can reference ones defined previously
  • Parameters defined with << or in table format cannot reference ones defined previously, not even those defined with =

Example: https://github.com/emlun/spock-parameter-cross-reference-fail/blob/master/src/test/groovy/Foo.groovy

It would also be nice if parameters in table format could reference other parameters as well, but I suspect its usefulness is more limited.

Status: New

Labels:
Type-Enhancement Module-Core