我正在项目中尝试存根的示例,但出现错误:Cannot resolve method 'willReturn' in 'Object'
这是一个例子:
@Test
public void exactUrlOnly() {
stubFor(get(urlEqualTo("/some/thing"))
.willReturn(aResponse()
.withHeader("Content-Type", "text/plain")
.withBody("Hello world!")));
}
如果我编译的项目会有这个错误:
java: cannot find symbol
symbol: method willReturn(com.github.tomakehurst.wiremock.http.ResponseDefinition)
location: class java.lang.Object
有人知道怎么修吗?
找到原因,Intellij在我键入get
:时自动完成了导入
import static javax.swing.UIManager.get;
应该是
import static com.github.tomakehurst.wiremock.client.WireMock.get;