[英]Spring Boot - Rest Assured methods not found
I have a REST API built with Spring Boot. 我有一个用Spring Boot构建的REST API。
I am attempting to use Rest-Assured test framework, however I can't seem to get it to work. 我正在尝试使用Rest-Assured测试框架,但是我似乎无法使其正常工作。
I am using the guide from Here 我正在使用这里的指南
get("/lotto").then().assertThat().body("lotto.lottoId", equalTo(5));
And have added the dependencies to my maven project. 并将依赖项添加到我的maven项目中。
<dependency>
<groupId>com.jayway.restassured</groupId>
<artifactId>rest-assured</artifactId>
<version>2.9.0</version>
<scope>test</scope>
</dependency>
However, It doesn't seem to import the required classes and just prompts me to create a new " get()"
method. 但是,它似乎没有导入所需的类,只是提示我创建一个新的“
get()"
方法。
My Test class: 我的测试班:
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(Application.class)
@WebIntegrationTest
public class DemoControllerTest {
@Test
public void test() {
get("/lotto").then().assertThat().body("lotto.lottoId", equalTo(5));
}
}
What am I missing? 我想念什么?
What am I missing?
我想念什么?
A simple static
import, that's missing! 一个简单的
static
导入,丢失了! In order to resolve the get
static method, just use the following static
import: 为了解决
get
static方法,只需使用以下static
导入:
import static com.jayway.restassured.RestAssured.get;
I had similar issue. 我有类似的问题。 What I did (using new version 3.0.2):
我做了什么(使用新版本3.0.2):
import io.restassured.RestAssured.*;
import io.restassured.matcher.RestAssuredMatchers.*;
import org.hamcrest.Matchers.*;
Instead of: 代替:
import static io.restassured.RestAssured.*;
import static io.restassured.matcher.RestAssuredMatchers.*;
import static org.hamcrest.Matchers.*;
So I had same issue couldnt find the methods ... 所以我有同样的问题找不到方法...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.