@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment=WebEnvironment.MOCK)
@AutoConfigureMockMvc
public class BoardControllerTest {
@Autowired
private MockMvc mockMvc;
@Test
public void testHello() throws Exception {
mockMvc.perform(get("/hello").param("name", "둘리"))
.andExpect(status().isOk())
.andExpect(content().string("Hello: 둘리"))
.andDo(print());
}
}
테스트 코드 일케 날렸는데
MockHttpServletResponse:
Status = 404
Error message = null
Headers = [Vary:"Origin", "Access-Control-Request-Method", "Access-Control-Request-Headers"]
Content type = null
Body =
Forwarded URL = null
Redirected URL = null
Cookies = []
2019-12-21 00:58:19.197 INFO 23596 --- [extShutdownHook] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'
이렇게 404 널로 응답이 오거든? 예제대로 라면 200이 나와야 되는데 어떤 문제가 있는걸까 ㅠ
컨트롤러 코드도 같이 올려줘야 알지