Lucky
Lucky

Reputation: 43

unable to read data from csv file using SerenityParameterizedRunner

I am using serenitybdd to load the data from csv file but my code is unable to fetch the values from csv . Its showing null values for both xyz and abc when i am trying to print in @test metho i_setup_the_request_fields() below. What did i do wrong here?

Here is the code of java and csv file.

@RunWith(SerenityParameterizedRunner.class)
@UseTestDataFrom(value="template/test/data/response/test.csv")
public class TestCustomSteps {


private String abc;
private String xyz;

@Steps
RestAssuredSteps restAssuredSteps;



public void setAbc(String abc) {
    this.abc = abc;
}


public void setXyz(String xyz) {
    this.xyz = xyz;
}


@Qualifier
public String qualifier() {
    return abc + "=>" + xyz;
}

@Test
@Given("I setup the request fields")
public void i_setup_the_request_fields() {
    // Write code here that turns the phrase above into concrete actions

    System.out.println(abc+"--"+xyz);
    Map<String,String> mapData = new HashMap();
    mapData.put("abc",abc);
    mapData.put("xyz",xyz);

    restAssuredSteps.setRequestFields(mapData);
}



}

and csv file

abc,xyz 6543210987654321,10000 6543210987654320,10000

Upvotes: 0

Views: 1016

Answers (1)

Ilyas Patel
Ilyas Patel

Reputation: 450

A few things you can try one at a time:

  1. You setter methods are not named the same as your private variables:

Try changing your variable names to cloakPan and memberId or change your setter methods to match your variable names.

  1. @UseTestDataFrom(value="template/test/data/response/test.csv")

Maybe hard-code the full path to the file name (from root) just to make sure it is looking in the right place.

  1. There is an example here, copy that to see if that works - http://thucydides.info/docs/thucydides/_data_driven_testing_using_csv_files.html

Upvotes: 0

Related Questions