1

I'm working in rest api testing. Currently I test when request send and json response generate or not. I'm test with positive and negative values to put in parameters in the url. Now I need to test so many case like...

Other possible test cases:

  • What happens if you send malformed requests to the API?

    • Does your API have state? I.e., are there any logical sequences of API calls (e.g., login, search item, place item in cart, checkout) that influence API behavior?
  • What's the API performance?
  • Is the API secured? If so, can you break the security?

How to perform these possible cases ? or Is there any extra possible test case are there ? please tell anybody..

Here is my code what should I need to test ? What are the possiblities that I need to test in rest api ? Or anything else needed in rest api testing?

package com.qber.test;

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

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

/**
 * Created by naveen on 15/12/16.
 */
public class registerCounter {
    @Test(dataProvider = "register")
    public void md5JsonTest(String secret,String mac,String id, String md5Hash) {

        given().
                parameters("s", secret).parameters("m",mac).parameters("d",id).
                when().
                get("http://baseUrl/register/device").
                then().
                assertThat().
                body("md5", equalTo(md5Hash));
    }

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

        return new String[][] {
                {"1c40f4","063f98d2621038a7af64ba893f2540e0","10","REG_DEV_01"}
        };
    }

}

In my project there were 25 api are there I just made 25 separate class files for api's and test with same code. is it correct or not ? What should I need to do ? Anybody please help me to give a valuable answer

  • 1
    This is way too broad for a single question, and depends on how your API handles data: whether it requires an auth code for some or all calls, whether it persists data or not, what it specifies should happen under which circumstances... The only accurate answer anyone can give you is "It depends" – Kate Paulk Dec 15 '16 at 16:10