How do you set a base URI for all requests in RestAssured?

How do you set a base URI for all requests in RestAssured?

A) RestAssured.baseURI
B) setBaseURI()
C) configureBaseURI()
D) withBaseURI()

Answer:

A) RestAssured.baseURI

Explanation:

The RestAssured.baseURI field is used to set a base URI for all requests in RestAssured. This allows you to avoid repeating the base URI in every request.

For example:


import static io.restassured.RestAssured.*;

RestAssured.baseURI = "https://api.example.com";

given().
    when().
    get("/resource").
    then().
    statusCode(200);

In this example, the baseURI is set to “https://api.example.com”, and all subsequent requests will use this base URI by default.

Reference links:

https://www.javaguides.net/p/top-java-libraries.html

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top