title: Is it possible to use data tables to assign to a @Shared variable?
body: <p>I'm dealing with a series of tests which are pretty redundant, that assign a value to an inherited <code>@Shared</code> variable for use in successive test classes, like so:</p>
  
  <pre><code>def "test1"() {
      when:
          sharedVar1 = doSomething(10, 20)
      then:
          sharedVar1 &gt; 0
  }
  
  def "test2"() {
      when:
          sharedVar2 = doSomething(3, 7)
      then:
          sharedVar2 &gt; 0
  }
  
  ...
  </code></pre>
  
  <p>There can be upwards of eight of these in a row, all doing exactly the same thing, just with different variables.</p>
  
  <p>I attempted to make this simpler using <code>@Unroll</code> and data tables, like so:</p>
  
  <pre><code>@Unroll
  def "test #n"() {
      when:
          localVar = doSomething(a, b)
      then:
          localVar &gt; 0
      where:
          localVar   | a  | b  | n
          sharedVar1 | 10 | 20 | 1
          sharedVar2 | 3  | 7  | 2
          ...
  }
  </code></pre>
  
  <p>But I've come across the (in hindsight) obvious problem where the assignment in the <code>when:</code> block is assigning the value to the <em>local</em> variable <code>localVar</code> and not the <em>shared</em> variable that I want to assign the value to.</p>
  
  <p>Is there any simple way to use the data-table/data-pipe style of writing these tests that allows me to assign to the shared variables, or am I essentially limited to only using this style of testing when I <em>don't</em> need to assign values to shared variables?</p>