【问题标题】:Rest Assured cannot be resolved to a variableRest Assured 无法解析为变量
【发布时间】:2021-03-30 21:40:42
【问题描述】:

我创建了一个 java 项目并在我的控制台中收到错误

线程“main”java.lang.Error 中的异常:未解决的编译问题: RestAssured 无法解析为变量

添加了 jar-rest-assured-4.3.3-dist.zip-全部提取 来自官网-https://github.com/rest-assured/rest-assured/wiki/Downloads

    here is my code-
   
//java class basics
    import io.restassured.RestAssured;
    import static io.restassured.RestAssured.*;
    
    
    public class Basics {
    
    
    public static void main(String[] args) {
  
//adding given, when , then conditions
  
    RestAssured.baseURI = "https://rahulshettyacademy.com";  //added the base URI here 

//adding given condition here with log report
        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\": \" Muzammil 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" +`enter code here`
        "}")                                            // end of body 
        .when().post("maps/api/place/add/json")       // added the resource here
        .then().log().all().assertThat().statusCode(200); // validating response here
        
        }
        
        }
    
    

我该如何解决这个问题?

【问题讨论】:

  • 我的电子邮件ID; muzifire@gmail.com

标签: rest rest-assured


【解决方案1】:

我假设您使用的是 maven。如果是这种情况,您需要删除

<scope> test 

node 在 pom.xml 文件中形成您放心的依赖关系。如果您没有使用 maven,请尝试设置构建路径并确保已将所有 .jar 文件添加到项目中。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-04-14
    • 2021-12-21
    • 2012-02-29
    • 2020-12-07
    • 2019-04-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多