Rest Assured API for Rest Service Integration testing

We use Rest Assured Api for testing the Rest services. Its very easy to implement. It works based on Given when then approach


public class RestAssuredTest{
    
    @Before
    public void setUp() {
        RestAssured.baseURI = "http://localhost"; //Domain name
        RestAssured.port = 8080; //port number
        RestAssured.basePath = "/api/"; //Service Base URL
    }

    @Test
    public void testRestService() {
        Response res = given().param("QUERY_PARAM", "QUERY_VALUE").get("REST SERVICE PATH");
        assertEquals(200, res.getStatusCode());
        assertNotNull(res.getBody());
res.getBody().asString());     
    }
}

Please refer my another posts for more information Rest Assured – Example and Rest Assured – Test Secure web services

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s