Skip to content

Instantly share code, notes, and snippets.

@MenukaIshan
Created December 9, 2016 10:51
Show Gist options
  • Save MenukaIshan/c62438390688edf94eb470fc889f992b to your computer and use it in GitHub Desktop.
Save MenukaIshan/c62438390688edf94eb470fc889f992b to your computer and use it in GitHub Desktop.
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