0

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

Lucky
  • 33
  • 4

1 Answers1

0

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
Ilyas Patel
  • 400
  • 2
  • 11
  • 27
  • Thanks for your response, 1. sorry I forgot to replace the actual setter method and params with abc and xyz. but its not the problem for sure. 2. I tried with both absolute and relative path but problem is same 3, I take a look into example from here but still the same issue. – Lucky Apr 05 '20 at 03:07