title: Spock Spring boot testing
body: <p>I am in the initial stage of spock and groovy, I am trying to test one simple spring boot application and getting </p>
  
  <p>Below is my java and groovy code with exception details</p>
  
  <pre><code>Condition not satisfied:
  
  mvc.perform(get('/hello')).andExpect(status().isOk())
  |           |
  |           groovy.lang.MissingMethodException: No signature of method: org.spockframework.controllers.TestControllerSpec.get() is applicable for argument types: (java.lang.String) values: [/hello]
  |           Possible solutions: getAt(java.lang.String), grep(), grep(java.lang.Object), wait(), Spy(), getMvc()
  org.springframework.test.web.servlet.MockMvc@6bb68f5
  
  at org.spockframework.controllers.TestControllerSpec.spring context loads for web mvc slice(TestControllerSpec.groovy:28)
  Caused by: groovy.lang.MissingMethodException: No signature of method: org.spockframework.controllers.TestControllerSpec.get() is applicable for argument types: (java.lang.String) values: [/hello]
  Possible solutions: getAt(java.lang.String), grep(), grep(java.lang.Object), wait(), Spy(), getMvc()
  
  and above exception comes when some argument is missing don't what argument and how to pass argument below is my code
  </code></pre>
  
  <p>TestController.java</p>
  
  <pre><code>@RequestMapping(value = "/hello")
  @ResponseBody
  public String sayHelloWorld() {
      return "hello world";
  }
  </code></pre>
  
  <p>TestControllerSpec.groovy </p>
  
  <pre><code>import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status
  
  import org.springframework.beans.factory.annotation.Autowired
  import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest
  import org.springframework.boot.test.context.TestConfiguration
  import org.springframework.context.annotation.Bean
  import org.springframework.test.context.ContextConfiguration
  import org.springframework.test.web.servlet.MockMvc
  import org.springframework.test.web.servlet.request.MockMvcRequestBuilders
  
  import spock.lang.Specification
  import spock.lang.Unroll
  import spock.mock.DetachedMockFactory
  
  @ContextConfiguration
  @WebMvcTest(TestController)
  class TestControllerSpec extends Specification {
  
   @Autowired
   MockMvc mvc;
  
   @Unroll
   def "spring context loads for web mvc slice"() {
  
      expect: "controller is available"
      mvc.perform(get('/hello')).andExpect(status().isOk())
   }
  
   @TestConfiguration
   static class MockConfig {
      def detachedMockFactory = new DetachedMockFactory();
   }
  }
  </code></pre>
  
  <p>I am sure my code is missing something</p>