使用spring boot 进行静态测试得时候得导入这几个包。不然断言内得方法无法被调用,网上很多大哥都是复制粘贴得,所以没有这方面得细节,照着他们打肯定会报错得
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static org.hamcrest.Matchers.equalTo;
另外
1. 要用junit中的assertThat来进行断言,记住静态导入
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;