Home > Enterprise >  Caused by: io.cucumber.datatable.UndefinedDataTableTypeException: Can't convert DataTable to in
Caused by: io.cucumber.datatable.UndefinedDataTableTypeException: Can't convert DataTable to in

Time:08-03

I have am keep getting this error when i use integer, string, and cucumber data table in my step

Here is the code example:

feaureFileExample.feature

Scenario: my scenario
      Given "url" post request sent with following data and count is 2
        | name| lastname| setIconURL       |
        | firstname | lastname| www.iconURL1.com |

StepDefnition.java

@Given({string} post request sent with following data and count is {int})
public voide myTestStep(String URL, DataTable dataTable,int countValue)
{
   int(int i=0;i<=countValue;i  )
   {
   List<Map<String, String>> competionData = dataTable.asMaps(String.class, String.class);
   //Here my logic to execute this step 2 times as count == 2

   }
}

Error: i

io.cucumber.core.exception.CucumberException: Could not convert arguments for step [{string} post request sent with following data and count is {int}] defined at 'StepDefinitions.somelocation.myTestStep(java.lang.String,io.cucumber.datatable.DataTable,int)'.
    It appears you did not register a data table type

Please let me know what is causing the issue FYI if I remove int value from step it's working fine. i don't want to hard code count value.

CodePudding user response:

You should change the order how you define your method parameters. So the below would work:

@Given("{string} post request sent with following data and count is {int}")
public void myTestStep(String URL, int countValue, DataTable dataTable)
{
   for(int i=0;i<=countValue;i  )
        {
            List<Map<String, String>> competionData = dataTable.asMaps(String.class, String.class);
            //Here my logic to execute this step 2 times as count == 2

        }
}
  • Related