incompatible types JsonPathResultMatchers cannot be converted to org.springframework.test.web.servlet.ResultMatcher
개발이야기 2021. 4. 1. 22:47package com.kknd.brave.springboot.web;
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.assertj.core.internal.bytebuddy.matcher.ElementMatchers.is;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
import static org.hamcrest.Matchers.is;
@RunWith(SpringRunner.class)
@WebMvcTest(controllers = HelloController.class)
public class HelloControllerTest {
@Autowired
private MockMvc mvc;
@Test
public void helloReturn() throws Exception {
String hello = "hello";
mvc.perform(get("/hello"))
.andExpect(status().isOk())
.andExpect(content().string(hello));
}
public void helloDtoReturn() throws Exception {
String name = "Hello";
int amount = 10000;
mvc.perform(
get("/hello/dto")
.param("name", name)
.param("amount", String.valueOf(amount)))
.andExpect(status().isOk())
.andExpect(jsonPath("$.amount", is(amount)))
.andExpect(jsonPath("$.name", is(name)));
}
}
import import static org.assertj.core.internal.bytebuddy.matcher.ElementMatchers.is 되어 있는걸
import static org.hamcrest.Matchers.is; 변경한다.
'개발이야기' 카테고리의 다른 글
IntelliJ Github 연결시 404 Not Found (0) | 2021.03.28 |
---|---|
_.each function break 구문사용하기 (0) | 2020.01.14 |
mac 에서 갑자기 ls , vi 명령어가 작동하지 않을때 (0) | 2019.11.17 |
Udemy 강좌 빠른속도로 보는 방법, Udemy 강좌가 느릴때 (0) | 2019.05.06 |
lombok.javac.apt.LombokProcessor could not be initialized. Lombok will not run during this compilation (0) | 2019.04.23 |