title: Byte-buddy and cglib not available in Spock test
body: <p>I started playing around with Spock testing framework and my <code>build.gradle</code> dependencies section looks like this:</p>
  
  <pre><code>dependencies {
      testCompile "org.spockframework:spock-core:1.3-groovy-2.5"
  }
  </code></pre>
  
  <p>I have a (useless) Spock test that requires creation of a stub:</p>
  
  <pre><code>def 'A test that will fail'() {
      given: ''
      def random = Stub(Random)
  }
  </code></pre>
  
  <p>When launched, the test fails with the given error:</p>
  
  <blockquote>
    <p>CannotCreateMockException: Cannot create mock for class java.util.Random. Mocking of non-interface types requires a code generation library. Please put an up-to-date version of byte-buddy or cglib-nodep on the class path.</p>
  </blockquote>
  
  <p>This error is mentioned in <a href="http://spockframework.org/spock/docs/1.3/interaction_based_testing.html#Stubs" rel="nofollow noreferrer">Spock documentation</a> and it's caused by cglib or byte-buddy not being available at runtime.</p>
  
  <p>Considering that <a href="https://search.maven.org/artifact/org.spockframework/spock-core/1.3-groovy-2.5/jar" rel="nofollow noreferrer">spock-core's pom lists both byte-buddy and cglib as compile dependencies</a>, why are they not retained at runtime? In other words, why do we need to explicitly add the following runtime dependency to our build.gradle file?</p>
  
  <pre><code>testRuntime "net.bytebuddy:byte-buddy:1.9.3" 
  </code></pre>