1

The main problem is that example table is too long (below the example is a mock short, my real test would be ~300 lines). Is it possible to generate these table? I have mypage30.. it would be hard to maintain it

Scenario Outline: Check categories
Given I visit '<mypage>'
When I select '<category>'
Then the selected category is shown

Examples: 
| mypage | category |
| page1  | mouse    |
| page1  | cat      |
| page1  | horse    |
| page1  | do       |
| page1  | duck     |
| page2  | mouse    |
| page2  | cat      |
| page2  | horse    |
| page2  | do       |
| page2  | duck     |

1 Answers1

1

It's impossible to generate a content of .feature file automatically.

Yet I guess in your case you can make it other way.

One way is to store your table in .xlsx file and to use this file as a data source.

If you choose this option, it's very simply implemented in SpecFlow: https://specflow.org/plus/documentation/Prepare-feature-files-for-external-examples/ All you need is to specify the path to your source file:

@source:CalculatorExamples.xlsx
Examples:
    | case | a | b | result |

Another way is to generate all the data within your test scenario. I don't know how you wanted to generate this table so I assume that the first way is better.

Denis Koreyba
  • 3,144
  • 1
  • 31
  • 49
  • the xlsx file solution is only available for specflow+ Can you write an example for the other way, when generate data in test scenario – Tibor Kovács Oct 08 '18 at 08:16
  • 1
    @TiborKovács load file in a step definition and use it as a source. It will be a little bit harder as you need to parse it by yourself. – Denis Koreyba Oct 08 '18 at 08:32