这是关于 Rest-assured 框架的非常基本和简单的问题。我一直在尝试使用一些参数连接到天气网络服务 api。但我一直拒绝连接。我无法找出真正尝试连接的 URL。
given().
param("APPID","xxxxxx").
param("q","London").
get(EndPoint.GET_ENDPOINT).
then().
statusCode(200).
log().everything();
Run Code Online (Sandbox Code Playgroud)
得到这个:java.net.ConnectException:连接被拒绝。
我想在我的控制台中打印出连接 URL。你知道怎么做吗?
小智 7
将.log().all()部分移动到`.given()?部分,它应该将其打印到控制台:
given().log().all()
.param(…)…
Run Code Online (Sandbox Code Playgroud)
RestAssured将它将构造的 URL 的所有部分存储为静态变量。
System.out.println(RestAssured.baseURI + ":" + RestAssured.port + RestAssured.basePath + EndPoint.GET_ENDPOINT);
Run Code Online (Sandbox Code Playgroud)
我不知道有什么方法可以将它们结合起来,尽管我认为这对于静态方法或可能在RequestSpecification.