我从"https://github.com/rest-assured/rest-assured/wiki/Downloads"导入了jar文件,前6个。 而且,我已经导入了静态类"import static io.restassured.RestAssured.*",但仍然得到这个编译错误。 除了上述错误之外,我还收到此错误"包io.restsure不存在"。
我的 Maven 依赖项也如下:
<!-- rest assured library for API-level testing -->
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>4.3.0</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/io.rest-assured/json-path -->
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>json-path</artifactId>
<version>3.0.3</version>
</dependency>
<!-- to validate that a JSON response conforms to a Json Schema -->
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>json-schema-validator</artifactId>
<version>3.0.2</version>
</dependency>
代码片段:
public static List<String> passParams(List<String> list){
RestAssured.baseURI = freightRootURL;
RequestSpecification requestSpecification = given();
for (int i = 0; i < list.size() ; i ++ ) {
requestSpecification = requestSpecification.queryParam(freightParams.get(i), list.get(i));
}
String result = requestSpecification.when().get().then().assertThat().statusCode(200).extract().response().asString();
JsonPath js = new JsonPath(result);
String offers = js.getString("offers.key");
return Arrays.asList(offers.split(","));
添加依赖项解决了这个问题
使用了 https://code.quarkus.io/中的 Stsarter 项目,并在之后添加了依赖项