title: Is there a way to use @MockBean annotation while working with Spock framework
body: <p>I was trying out Spock and encountered an interesting problem when writing controller-tests. </p>
  
  <pre><code>WebMvcTest(value = SomeController.class)
  @AutoConfigureMockMvc
  @ActiveProfiles(value = "restapi")
  @Import(value = SecurityConfiguration)
  class AccountBalanceControllerTest extends Specification {
  
  @Autowired
  SomeController someController
  
  @MockBean
  SomeService someService
  
  def "lets test it" {
    given: 
        someService.findAllByName(_) &gt;&gt; ["Some", "Work"]
    when:
      def response = mockMvc.perform(get("/v1/someName/545465?fast=false").with(user("mvc-test").roles("SOME_ACCOUNTS")))
    then: 
        response.andExpect(status().isOk()) 
  }
  
  
  }
  </code></pre>
  
  <p>So the problem is mocking method on <code>SomeService</code> instance does not work because it uses a different Mock class for mocking the instance of <code>SomeService</code>  class. I got a work around using the static Mock method from Spock in the setup and then using a setter to set <code>SomeService</code> in the controller. My question is there any elegant way to use <code>@MockBean</code> with Spock <code>Specification</code> testing.</p>