0
votes

I have a @Test which sends post request. Request body is passed as JSON payload. I want to pass multiple account id's to to same test rather than writing mutliple tests.

Request body is stored in payload.java file


    public static String account(String account_id){

        return "{\n" +
                "\"data\": {\n" +
                "\"type\": \"ACCR\",\n" +
                "\"id\": \""+ account_id +"\"\n" +
                "}\n" +
                "}";
    }
}

Tests are written in account.java file

public class acm_account_tests {
@Test
    public static void send_validRequest() throws IOException {

         String response = given()
                            .header("content-type", "application/json")
                            .body(account("A1234")) // here I want to pass multiple accounts
                            .when().post("https://abcd.com")
                            .then().statusCode(200)
                            .extract()
                            .response(). asString();
   
    } }

The above test works fine. How can I re-use the above test and pass multiple account numbers in request body?

Any help is much appreciated.