RestAssured

Now I am going to add a new Rest API test to this framework.

Let’s visit this website: https://github.com/rest-assured/rest-assured/wiki/GettingStarted

Add the maven dependency to the pom.xml as the above page suggests. Now we can add a test.

package com.directly.potassium;

import org.testng.annotations.Test;
import static io.restassured.RestAssured.*;
import static org.hamcrest.CoreMatchers.*;

public class SampleApiTest extends BaseTest {
@Test
void kvstoreTest() {
String path = getPropStr("kvstore.Host") + getPropStr("kvstore.Path.Parakeet") + getPropStr("kvstore.testKey");

given().
headers("kvstoreio_api_key", getPropStr("kvstoreio_api_key")).
when().
get(path).
then().
body("value", is(getPropStr("kvstore.testExpected.value")));
}
}

We can run this test by: mvn test -Dtest=SampleApiTest