title: Spock: How to properly share features between implementations of Specification
body: <p>I encountered an unfortunate aspect of Spock Framework (1.3-groovy-2.5), which I use for integration testing of a Gradle plugin.</p>
  <p><strong>The code sample</strong></p>
  <p>Parent class:</p>
  <pre><code>class ClassA extends Specification {
  
      def setupSpec() {
          System.out.println(&quot;In ClassA setupSpec()&quot;)
      }
  
      def &quot;base feature&quot;() {
          expect:
          true
      }
  }
  </code></pre>
  <p>Child class:</p>
  <pre><code>class ClassB extends ClassA {
  
      @Override
      def setupSpec() {
          System.out.println(&quot;In ClassB setupSpec()&quot;)
      }
  
      def &quot;extended feature&quot;() {
          expect:
          true
      }
  }
  </code></pre>
  <p>When I run tests in <code>ClassB</code>, both versions of <code>setupSpec()</code> are called:</p>
  <pre><code>In ClassA setupSpec()
  In ClassB setupSpec()
  </code></pre>
  <p>Of course, if I call method via native Groovy ways:</p>
  <pre><code>class Main {
  
      static void main(String[] args) {
          ClassB classB = new ClassB()
          classB.setupSpec()
      }
  }
  </code></pre>
  <p>Then I see only what is expected:</p>
  <pre><code>In ClassB setupSpec()
  </code></pre>
  <p>So, evidently, this is a Spock feature of some kind.</p>
  <p><strong>Question</strong></p>
  <p>In practice, what is the suggested way of inheriting from implementations of <code>Specification</code> while overriding setup logic?</p>