Created
          December 9, 2016 10:51 
        
      - 
      
 - 
        
Save MenukaIshan/c62438390688edf94eb470fc889f992b to your computer and use it in GitHub Desktop.  
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import hsenid.config.WebConfig; | |
| import org.springframework.beans.factory.annotation.Autowired; | |
| import org.springframework.http.MediaType; | |
| import org.springframework.test.context.ContextConfiguration; | |
| import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; | |
| import org.springframework.test.context.web.WebAppConfiguration; | |
| import org.springframework.test.web.servlet.MockMvc; | |
| import org.springframework.test.web.servlet.setup.MockMvcBuilders; | |
| import org.springframework.web.context.WebApplicationContext; | |
| import org.testng.annotations.Test; | |
| import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; | |
| import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; | |
| @Test | |
| @WebAppConfiguration | |
| @ContextConfiguration(classes = WebConfig.class) | |
| public class HomeControllerTest extends AbstractTestNGSpringContextTests { | |
| @Autowired | |
| private WebApplicationContext wac; | |
| private MockMvc mockMvc; | |
| @Test | |
| public void homeTest() throws Exception { | |
| this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build(); | |
| this.mockMvc.perform(get("/home", "/") | |
| .accept(MediaType.ALL)) | |
| .andExpect(status().isOk()) | |
| .andExpect(view().name("/home/self-care-home")); | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment