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 scenario by clicking the “grid” icon, next to the speech icon used to create a free text step.
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:
As with the Gherkin syntax, Hiptest expect a table formatted with “|” characters.
The table is set as an action word argument. The test case will look like this:
If we have a look at the action word, we can see that it now have a __datatable parameter:
Note that, as with the free text parameter, it is mandatory to keep name “__datatable”, otherwise it will not behave as a table but as a classic parameter.
When exporting the tests with non-Gherkin based tests 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 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 end end
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.