什么是“LocalTestServerContext”以及如何使用它?

What is `LocalTestServerContext` and how do I get to use it?

我正在使用 google 地图 API,特别是地理编码 API,在有关如何使用它的示例中,他们输入了以下内容:

    @Test
  public void testReverseGeocode() throws Exception {
    try (LocalTestServerContext sc = new LocalTestServerContext(reverseGeocodeResponse)) {
      LatLng latlng = new LatLng(-33.8674869, 151.2069902);
      GeocodingResult[] results = GeocodingApi.newRequest(sc.context).latlng(latlng).await();

      assertEquals(10, results.length);
      assertEquals("343 George St, Sydney NSW 2000, Australia", results[0].formattedAddress);
      assertEquals(
          "York St Near Barrack St, Sydney NSW 2017, Australia", results[1].formattedAddress);
      assertEquals("Sydney NSW 2000, Australia", results[2].formattedAddress);

      sc.assertParamValue(latlng.toUrlValue(), "latlng");
    }
  }

但是我的 android 工作室不承认 LocalTestServerContext 是一个东西。我在 youtube 上搜索了一下,没有找到任何有用的东西

LocalTestServerContextJava Client for Google Maps Services 的一部分,但仅用于测试目的(因为已定义到 src/test/java/com/google/maps/LocalTestServerContext.java)。

您应该作为依赖项包括在内,例如仅用于测试

<dependency>
    <groupId>com.google.maps</groupId>
    <artifactId>google-maps-services</artifactId>
    <version>0.18.2</version>
</dependency>