Api Quick Start Guide

Quick Start guide for api automation using Ekam

Execute an example test

Step 1: Open the example api test

Open src/java/ekam/example/api/ApiExampleTest.java. This test invokes get address Faker API and returns the address.

package ekam.example.api;

import com.testvagrant.ekam.testBases.testng.APITest;
import ekam.example.api.getAddress.GetAddressClient;
import ekam.example.api.getAddress.model.GetAddressResponse;
import io.qameta.allure.Issue;
import io.qameta.allure.TmsLink;
import io.qameta.allure.TmsLinks;
import org.testng.annotations.Test;

import static com.testvagrant.ekam.commons.LayoutInitiator.Client;
import static org.testng.Assert.assertEquals;

public class ApiExampleTest extends APITest {

    @TmsLinks({@TmsLink("TC-API-001"), @TmsLink("TC-API-2")})
    @Issue("Issue-001")
    @Test(groups = "api", description = "Should get address by query parameter")
    public void shouldGetAddressSuccessfully() {

        // 1. Arrange
        int addressId = 1;

        // 2. Act
        GetAddressResponse response =
                Client(GetAddressClient.class).getAddress(addressId);

        // 3. Assert
        assertEquals(response.getStatus(), "OK");
        assertEquals(response.getCode(), 200);
        assertEquals(response.getData().get(0).getId(), addressId);

    }
}

Step 2: Execute the test

We need to make a IntelliJ IDEA setting change to execute tests via IDE

PreferencesBuild, Execution, DeploymentBuild ToolsGradle

Run tests using : IntelliJ IDEA

Lets execute test shouldGetAddressSuccessfully from IDE

Step 3: Execute the test from command line

Let us now run the test. From your terminal execute

./gradlew runApiTests

Step 4: View reports

Ekam, by default generates allure report. To view the recent run, execute the below command from terminal

./gradlew allureServe

The command once executed successfully will launch a report on your default browser.



Next steps

Congratulations!! you have successfully kick-started API test automation with Ekam. Now that we have executed a test, let us start writing a new test. Let’s move to Authoring first API Test.

Now, lets deep dive into API Test Automation