1

Here is a simple example:

 Scenario: Table example
    * table dogs
      | name      | age |
      | 'Charlie' | 2   |
      | 'Jack'    | 4   |
      | 'Rock'    | 9   |
    * match dogs == [{name: 'Charlie', age: 2}, {name: 'Jack', age: 4}, {name: 'Rock', age: 9}]

Is it possible to move table to another file, and just import it? If yes, how exactly?

Thanks in advance

2 Answers 2

1

If you are want to do this during design time, say, import a table from another data source, you can use some design tool CukeTest, which allow you to edit it visually, import data from a *.csv file into a Table or Example of the gherkin file. You can save a Excel data file to *.csv format.

If you want to do it at runtime, then there are a lot of ways to read data and parse it programmatically, typically from *.json file or *.csv file.

Sign up to request clarification or add additional context in comments.

Comments

0

For this use case I recommend using JSON instead of a table and it will import nicely and have the advantage of being editable by most IDE-s etc.

* def dogs = read('dogs.json')
* match dogs == [{name: 'Charlie', age: 2}, {name: 'Jack', age: 4}, {name: 'Rock', age: 9}]

You could do this also:

* call read('dogs.feature')
* match dogs == [{name: 'Charlie', age: 2}, {name: 'Jack', age: 4}, {name: 'Rock', age: 9}]

And in dogs.feature

Feature:
Scenario:
* table dogs
      | name      | age |
      | 'Charlie' | 2   |
      | 'Jack'    | 4   |
      | 'Rock'    | 9   |

EDIT: since some teams insist on Excel (which I don't recommend) refer to this answer also if applicable: https://stackoverflow.com/a/47954946/143475

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.