线程“主”中的异常java.lang.AssertionError:1个期望失败。 JSON路径结果[0] .name不匹配。预期:悉尼实际:空

时间:2019-07-04 16:52:43

标签: web-api-testing

我的代码是:

我的网址是:https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522,151.1957362&radius=1500&key=AIzaSyDXpXV_StgGWqllibu_sMzeRIuufmzn1BM

我再次创建了Api密钥并尝试。这是我使用的网址 https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522,151.1957362&radius=1500&key=AIzaSyDXpXV_StgGWqllibu_sMzeRIuufmzn1BM

我清楚地从邮递员的尸体中复制并粘贴了“悉尼”这个名字的拼写。它是内部结果[0]。我给出了路径结果[0] .name

我曾经获得以下网址的以下网站(我使用了Google提供的附近搜索示例)。

https://developers.google.com/places/web-service/search

import io.restassured.RestAssured;
import io.restassured.http.ContentType;

import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;

public class get_google_api {

    public static void main(String[] args) {

        RestAssured.baseURI="https://maps.googleapis.com";
        given().
              param("location","-33.8670522,151.1957362").
              param("radius","1500").
              param("key","AIzaSyDXpXV_StgGWqllibu_sMzeRIuufmzn1BM").
              when().
              get("/maps/api/place/nearbysearch/json").
              then().assertThat().statusCode(200).and().contentType(ContentType.JSON).
        //body("results[0].geometry.location.lat",equalTo("-33.8688197"));
             and().body("results[0].name",equalTo("sydney"));
    }

}
  

线程“ main”中的异常java.lang.AssertionError:1个期望失败。
  JSON路径结果[0]。名称不匹配。
  预期:悉尼
    实际:空

0 个答案:

没有答案