title: Integration and unit tests with MockMvc
body: <p>According to the documentation there are two ways to do this:</p>
  
  <p>First:</p>
  
  <pre><code>@RunWith(SpringRunner.class)
  @WebAppConfiguration
  @ContextConfiguration("my-servlet-context.xml")
  public class MyWebTests {
  
      @Autowired
      private WebApplicationContext wac;
  
      private MockMvc mockMvc;
  
      @Before
      public void setup() {
          this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
      }
  
      // ...
  
  }
  </code></pre>
  
  <p>This form uses the actual context of the application.</p>
  
  <p>And the second way:</p>
  
  <pre><code>public class MyWebTests {
  
      private MockMvc mockMvc;
  
      @Mock
      private MyService myService;
  
      @InjectMocks
      private MyController myController;
  
      @Before
      public void setup() {
          // Process mock annotations
          MockitoAnnotations.initMocks(this);
          this.mockMvc = MockMvcBuilders.standaloneSetup(myController)
                  .setCustomArgumentResolvers(new PageableHandlerMethodArgumentResolver()).build();
      }
  
      @Test
      public void testsForPost() throws Exception {
  
          Foo foo = new Foo();
  
          //given
          given(myService.findById(Matchers.anyLong())).willReturn(foo);
  
          //when
          this.mockMvc.perform((post("/foo")))
          //then
          .andExpect(status().isMethodNotAllowed())
          .andDo(print());
      }   
      ...
  }
  </code></pre>
  
  <p>With this method I am not using the application context.</p>
  
  <p>My question is, can I consider the first form as integration tests? And the second as unit tests?</p>
  
  <p>Otherwise what would be the best solution to do unit tests of SpringMVC.</p>