Answers for "How to measure and validate API response time?"

1

rest assured time response

import org.testng.annotations.Test;

import io.restassured.builder.RequestSpecBuilder;
import io.restassured.response.Response;
import io.restassured.specification.RequestSpecification;

import static io.restassured.RestAssured.given;

public class ExampleTest {
	@Test
	public void getResponseTime() {
		RequestSpecification requestSpec = new RequestSpecBuilder().build();
		requestSpec.baseUri("http://localhost");
		requestSpec.basePath("user/details");
		Response response = given().spec(requestSpec).get("/10");

		// Print response time
		System.out.println("Response Time : " + response.getTime());

	}
}
Posted by: Guest on June-17-2020

Browse Popular Code Answers by Language