title: How to inject spring beans into spock test
body: <p>I am new to spock. I am trying to write a spock unit test against a standalone java app that uses JDK 1.7, Spring 3.1, Groovy 1.8.6, Spock 0.6, Maven 3.0.4. A basic hello world spock test is working. However when I try to test spring beans, I find that they are not getting injected. I use the approach mentioned <a href="http://code.google.com/p/spock/wiki/SpringExtension" rel="noreferrer">here</a>. businessObjectDao is null within <em>when</em> block. How do I get this working?</p>
  
  <pre><code>@ContextConfiguration(locations = "classpath*:test-appContext.xml")
  class BusinessObjectPersistenceTest extends Specification {
      @Autowired
      BusinessObjectDao businessObjectDao
  
      def "business never set at least once"() {
          when:
              BusinessObjectDao.getBusinessObject()
          then:
              ...
      }
  }
  </code></pre>