테스트 할 내용 요청 주소 검증 입력 파라미터 검증 package xyz.devnews.web.controllers; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.servlet.MockMvc; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @RunWith(SpringRunner.class) @WebMvcTest(controllers = NewsController.class) public class NewsControllerTest { @Autowired private MockMvc mvc; @Test public void test01_access_root_context_test() throws Exception { // given // when // then this.mvc.perform(get("/")) .andDo(print()) .andExpect(status().isOk()) ; } }