Hire QA – Specialized in QA Recruitment, Technical Interviews and Testing Solutions

What is static import and why would you use it in REST Assured?

Category: Rest Assured

Static import is a Java programming language function that lets members (e.g., fields and methods) scoped as public static within their container class to be employed in Java code without mentioning the field’s defined class.

import static io.restassured.RestAssured.*;

public class EmpControllerTest {

    @Test

    public void testGetEmployees() {

           // with static import

           given();

           // without static import

           /**

           *  import io.restassured.RestAssured;

           *  RestAssured.given();

           */ 

    }

}

Leave a Reply

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