Forum Discussion

svazquez's avatar
svazquez
New Contributor
5 years ago

How to use/reference datatable columns in definition steps

Hi there:

 

We have several forms that we are developing and we're trying to create a single function that can be used to validate any of them by passing the list of fields.

 

We are looking to represent this in Hiptest/Cucumber Studio so we created the action word validate the fields in the form "form-name" where we pass a table (with each field's ID, type, label, etc.) as parameter. The challenge is when we're trying to create the action word's definition where we are usually able to reference parameters, but in the case of the datatable, we would need to use the columns to fill the variables. Nothing works there, I've tried the column-name directly, =column-name, "column-name"...

 

How can this be done? We do not want to use the datatable at the scenario level because that would mean running several runs of the same scenario one for each field, nor we want to add a line for each column as steps in the scenario as it could not be very re-usable once we start working on the other forms.

 

Attached are screenshots of the action word used in a scenario and the details of its definition.

 

Please let me know if you need any other information and I thank in advance for any help you can provide. 🙂

 

Sergio.

  • aslakhellesoy's avatar
    aslakhellesoy
    SmartBear Alumni (Retired)

    It sounds like you're trying to test that forms are built correctly. A form is not part of your problem domain (retail, finance, whatever). If your tests are about technical building blocks rather than business rules in your problem domain, then Cucumber is probably not the right tool for the job.

     

    The main purpose of Cucumber is to build a shared understanding of system behaviour (in business language) between various technical and non-technical stakeholders, and provide living documentation of how the system behaves. If this isn't your goal, it's usually better to use a more low level testing tool, like a unit testing tool.

     

    By using a unit testing tool you have much more control over how a test executes.

    • svazquez's avatar
      svazquez
      New Contributor

      Hi, and thanks for the fast reply! 🙂

       

      I apologize but I'm not sure what you mean with "A form is not part of your problem domain (retail, finance, whatever)". I agree that Cucumber Studio is helping us build that shared behavior of the application, and part of that is documenting the details of the form we will be developing and later testing (its label, placeholders, field type for validations, etc.). Maybe in this case the table could be written more business, but as long as the team understands its meaning, I think it will be fine.

       

      Also, isn't Cucumber Studio's goal to also assist on the automation of the testing? That is why I am trying to reduce the complexity of what will eventually be turned into a testing script.

       

      I know there are more verbose ways to do the same thing I'm trying to do with the table, but I was wondering if calling columns from a step datatable was possible. It does seem like a cleaner way to document (see examples below). If it's not possible to do this at the step/action word level it's also ok and we will have to go with the more verbose option or find another way. 🙂

       

      Thanks,

       

      Sergio.

       

      MORE VERBOSE OPTION

      ....

      Then the field "field-1" will be of type "string", with label "Name", placeholder "Enter Name" and will not be mandatory

      And the field "field-2" ...

      ...

      And the field "field-10" ...

       

      WITH THE TABLE

      ...

      Then the form "form-1" will have the following fields:

      |field-name|type|label|placeholder|

      |field-1|string|Name|Enter Name|

      |field-2|...|...|...|

      ...

      |field-10|...|...|...|