我已经导入了运行RestAssured程序所需的所有jars。但是面对这个错误。
import io.restassured.RestAssured;导入静态io.restassured.RestAssured.*;公共类bascis {
public static void main(String[] args) {
// TODO Auto-generated method stub
RestAssured.baseURI="https://rahulshettyacademy.com";
given().log().all().queryParam("key", "qaclick123").header("Content-Type","application/json")
.body("{\r\n"
+ " \"location\": {\r\n"
+ " \"lat\": -38.383494,\r\n"
+ " \"lng\": 33.427362\r\n"
+ " },\r\n"
+ " \"accuracy\": 50,\r\n"
+ " \"name\": \"Frontline house\",\r\n"
+ " \"phone_number\": \"(+91) 983 893 3937\",\r\n"
+ " \"address\": \"29, side layout, cohen 09\",\r\n"
+ " \"types\": [\r\n"
+ " \"shoe park\",\r\n"
+ " \"shop\"\r\n"
+ " ],\r\n"
+ " \"website\": \"http://google.com\",\r\n"
+ " \"language\": \"French-IN\"\r\n"
+ "}\r\n"
+ "\r\n"
+ "").when().post("maps/api/place/add/json").then().assertThat().statusCode(200);
}}
发布于 2021-10-05 08:31:00
为什么不使用maven来解决这个依赖问题呢?如果你愿意,你可以使用下面的步骤,它相当简单。
io.rest-assured rest-assured 4.4.0测试
mvn全新安装
发布于 2021-01-04 14:46:50
rest assured库是为在测试范围中使用而创建的。你不应该在main作用域中使用它。
必须在测试范围中使用rest assured库,如下所示:The import io.restassured.RestAssured cannot be resolved
我推荐使用gradle来管理依赖项。如果你愿意,你可以下载这个带有main,test结构的项目。除了对gradle和JUnit的支持外:https://github.com/developercancun/gradle-simple
git clone https://github.com/developercancun/gradle-simple.git从项目目录中的控制台运行
./gradlew clean build你可以在这里看到它的工作原理:https://imgur.com/a/GvNjFrn
https://stackoverflow.com/questions/65558201
复制相似问题