0

I'm using REST-Assured library with TestNG for receiving the response in a Response object as below.

Response response;

@Test
public void someTest() {
    RestAssured.baseURI = "some_valid_baseURI";
    RestAssured.basePath = "some_valid_endpoint";
    response =    RestAssured.given().contentType(ContentType.JSON).when().get();
}

I have several test methods like the above-mentioned method in a test class. Is there any way to intercept the response assignment so that I can, somewhere else (e.g. in a method annotated by an @AfterMethod), know that the method being used to get the response is the GET method?

PS: I did not find any in-built way in the REST-Assured library to do this.

Akshay Maldhure
  • 787
  • 2
  • 19
  • 38
  • I do not think you can use rest assured for this but you can store the information you need in variable and later can use that. – h4k3r Apr 07 '17 at 06:18
  • That would need me to do that for every test out there. Not a very good idea. Instead, I was thinking of some generic interceptor-like method which would work for all the test methods. – Akshay Maldhure Apr 07 '17 at 06:20

1 Answers1

0

The answer in Is it possible to extract the method name from the response object? serves my purpose for this question. Sorry about the generic question line here though!

Community
  • 1
  • 1
Akshay Maldhure
  • 787
  • 2
  • 19
  • 38