Join 500+ Software Testing professionals. Solve problem and get your problem solved. Register Now!

What is the best practice for rest-assurerd API automation testing?

Solved 2 Answers 134 Views
0 2

Hi all,

I am automating API using rest-assured tool, using JAVA.

My approach is as follows:

package com.restapi.test;

        import com.jayway.restassured.RestAssured;
        import org.testng.annotations.BeforeClass;

    public class baseUrl {
        public void setup() {

            String basePath = System.getProperty("server.base");
                basePath = "/tbiauth/";
            RestAssured.basePath = basePath;

            String baseHost = System.getProperty("");
                baseHost = "";
            RestAssured.baseURI = baseHost;



    package com.restapi.test;

    import org.testng.annotations.DataProvider;
    import org.testng.annotations.Test;

    import static com.jayway.restassured.RestAssured.given;
    import static org.hamcrest.CoreMatchers.containsString;

    public class KioskRegister extends baseUrl{

        @Test(dataProvider = "start")
        public void md5JsonTest(String access,String device ,String id,String md5Hash) {





        @DataProvider(name = "start")
        public Object[][] createMD5TestData() {

            return new String[][] {


Is my apporach right?

Is there any better approach to this?

2 Answers

Best answer

There is no best practice because technology is rest-assured.

We use cucumber to organize our tests. Some of the tests are UI oriented while others are API focused. For the latter, we use a mixture of rest-assured and DAO (for accessing database and business intelligence data warehouse back ends).

Cucumber supports Behavior Driven Development. Some of the Given, When, Then statements implement web testing. 

UI-based test execution is time-consuming. Endpoint tests and back-end tests have much shorter elapsed execution times. So using a testing pyramid only a small percentage of your tests should be UI focused.

Lastly, we execute our features in parallel to minimize total execution elapsed time.

answered by (143 points)
selected by

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.