我正在尝试使用eclipse运行以下代码但它会给我错误:“对于LastLabTest类型未定义的方法何时为”。我已经导入了库但仍然给了我这个错误。我正在使用带有junit5的eclipse。
import io.restassured.RestAssured;
import io.restassured.RestAssured.*;
import io.restassured.builder.RequestSpecBuilder;
import io.restassured.filter.log.RequestLoggingFilter;
import io.restassured.filter.log.ResponseLoggingFilter;
import io.restassured.http.ContentType;
import io.restassured.matcher.RestAssuredMatchers.*;
import io.restassured.specification.RequestSpecification;
import org.hamcrest.Matchers.*;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.BeforeClass;
import org.junit.jupiter.api.Test;
class LastLabTest {
private RequestSpecification specification;
@BeforeClass
public void inItSpec() {
specification = new RequestSpecBuilder()
.setContentType(ContentType.JSON)
.setBaseUri("http://openlibrary.org/")
.addFilter(new RequestLoggingFilter())
.addFilter(new ResponseLoggingFilter())
.build();
}
@Test
public void getByName() {
when().get("https://swapi.co/api/people/1")
.then().log().all()
.statusCode(200)
.and()
.body("name", equals("Luke Skywalker"));
}
}
答案 0 :(得分:0)
行中缺少关键字
static
import io.restassured.RestAssured.*;
=>
import static io.restassured.RestAssured.*;