我已经从"https://github.com/rest-assured/rest-assured/wiki/Downloads“(前6位)导入了jar文件,并且,我已经导入了静态类”ImportStaticio.Restassured.Restised.*“,但仍然得到了这个编译错误。除了上面的错误,我还得到了这个错误“包io.restassured不存在”。
另外,我的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(","));发布于 2022-03-17 07:25:09
添加依赖项解决了这个问题。
从https://code.quarkus.io/中使用stsarter projec,然后添加依赖项。
https://stackoverflow.com/questions/62009724
复制相似问题