인프런 커뮤니티 질문&답변
EventControllerTest
작성
·
305
0
테스트 할때 다음과 같은 함수가 에러가나요.
content() 이 함수가 빨간줄이 생기고 에러가 발생합니다.
@Test
public void getTest() throws Exception{
mockMvc.perform(get("/event/1"))
.andExpect(status().isOk())
.andExpect(content().string("1"));
}
그래서 다음과 같이 코드를 수정하면 빨간줄은 없어지는데
컴파일 에러가 발생합니다.
@Test
public void getTest() throws Exception{
mockMvc.perform(get("/event/1"))
.andExpect(status().isOk())
.andExpect((ResultMatcher) content().string("1"));
}
ㅠㅠ답변 기다리겠습니다. 감사합니다.
답변 1
1
백기선
지식공유자
content()를 잘못 import 하신게 아닐까 싶네요. static import를 할 때 ResultMatcher에 있는 context()를 import해야 합니다.





