-
카테고리
-
세부 분야
백엔드
-
해결 여부
미해결
EventControllerTest
19.12.19 22:29 작성 조회수 200
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
백기선
지식공유자2019.12.20
content()를 잘못 import 하신게 아닐까 싶네요. static import를 할 때 ResultMatcher에 있는 context()를 import해야 합니다.
답변 1