是否可以从响应对象中提取方法名称? [英] Is it possible to extract the method name from the response object?

查看:51
本文介绍了是否可以从响应对象中提取方法名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Java 中使用 REST-Assured,这是我获取 response 对象的方法:

I'm using REST-Assured in Java and here's how I'm getting my response object:

Response response = RestAssured.given().contentType(ContentType.JSON).header(header_name).get();

我想知道是否有任何方法可以从 response 对象中提取使用的方法名称(在本例中为 GET).

I want to know if there's any way to extract the method name used (GET in this case) from the response object.

推荐答案

如果你有兴趣知道请求的方法说 GET 或 POST,下面的代码将在控制台上打印该方法

Incase if you're interested in knowing the requested method say GET or POST, below code will print the method on the console

given().log().method()
        .when()
        .get("https://www.google.co.in/").then().statusCode(200);

希望能帮到你

这篇关于是否可以从响应对象中提取方法名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆