Search code examples
javacucumberrest-assuredcucumber-java

When I run the POST call through Rest assured (Examples keyword),first dataset requests run fine but with the second dataset values get clubbed


When I run the POST call through Rest assured framework(Cucumber Examples keyword), first dataset requests run fine but with the second dataset, both first dataset and second dataset values are getting merged. How can this be rectified?

Featurefile:

Given profile details with "name" and "profiletype"

Examples: | name | profiletype |

  | Davian | ADULT        |
  | Kavian | ADULT        |

Stepdefinition:

public void profile_details_with_and(String name, String profiletype) throws IOException {

    config.setProperty("Base.properties");
    testservice.setBaseURI();
    testservice.addQueryParam("at", config.getConfig().getProperty("at"));
    testservice.addHeaderCookie("COOKIE",config.getConfig().getProperty("COOKIE"));
    testservice.callRequestSpec();
    testservice.formParam("profilePic","default");
    testservice.formParam("locale","en");
    testservice.formParam("name",name);
    testservice.formParam("profileType",profiletype);
}

public void formParam(String key, String value) throws IOException{

    requestSpec = given().spec(setBaseURI()).contentType(ContentType.URLENC.withCharset("UTF-8")).formParam(key, value);
}

Logs Output:

Form params:

profilePic=[default, default]

locale=[en, en]

name=[Davian, Kavian]

profileType=[ADULT, ADULT]

Solution

  • Write a seperate scenario for each example. Then you can isolate the issue. In general keep you scenarios simple even if it means a bit of repition. You don't need to use example groups or scenario outlines to cuke effectively.