Using step datatable

As the free text parameter, there is another special parameter that can be used in Hiptest: the step datatable.

This kind of parameter can be added from a step by clicking on the menu and selecting “Add table parameter” to create a step datatable parameter.
Let’s consider the following scenario:

We need to provide Hiptest the list of existing users in the system. This could be done by using the scenario datatable but it would generate multiple tests and use only one row by test.
We can use a step datatable to fix that problem:

Hiptest step datatable

As with the Gherkin syntax, Hiptest expects a table formatted with “|” characters.

The table is set as an action word argument. The test case will look like this:

Hiptest test with datatable step

If we have a look at the action word, we can see that it has now a __datatable parameter:

Hiptest actionword datatable parameter

Note that, as with the free text parameter, it is mandatory to keep the name “__datatable”, otherwise it will not behave as a table but as a classic parameter.

Automating the datatable

Non-Gherkin frameworks

When exporting the tests with non-Gherkin based test frameworks, the datatable is passed to the action word as a string.
You will have to implement your own way to handle the data, but the code is pretty simple (here is a Ruby-ish treatment):

treated = datatable.split("\n").map do |line|
  line.split("|").map do |cell|
    cell.trim() // trim removes white spaces around the content

Gherkin frameworks

The Gherkin based frameworks (Cucumber, Behave, Behat, Specflow) will handle the datatable and already provide you ways to access rows and cells.

One known issue with the code generation occurs with Specflow and Cucumber/Java. The generated steps_definitions file will be correct (by giving the Table or DataTable type to the datatable parameter) but the corresponding action word will consider the parameter as a string. This needs to be manually corrected while implementing the action word.

Download the ebook

By submitting this form, you agree to our Terms of Use and Privacy Policy

Hiptest is FREE for open source projects

We actually utilize a number of open source components, which is why Hiptest service is free for any open source project. We are giving back to the community!

Your open source project must meet the following criteria to be approved:

  • Your project is licensed under a license approved by the Open Source Initiative
  • Your project source code is available for download
  • Your project has a publicly accessible website