Sharing example tables between scripts

I have a file with 3 scripts to run some BDD tests in a C # project. Each script is demonstrated using a table with large examples (about 40 lines). Sample tables are the same. Here's what the function file looks like:

Scenario Outline: scenario1
 <stmt set 1>
 Examples:
 <LargeTable>

Scenario Outline: scenario2
 <stmt set 2>
 Examples:
 <LargeTable>

Scenario Outline: scenario3
 <stmt set 3>
 Examples:
 <LargeTable>

I do not like to repeat the same examples for each scenario. Is there a way to write an example table once and the scripts reference it, i.e. something like this:

Scenario Outline: scenario1
 <stmt set 1>
 Examples:
 <ref LargeTable>

Scenario Outline: scenario2
 <stmt set 2>
 Examples:
 <ref LargeTable>

Scenario Outline: scenario3
 <stmt set 3>
 Examples:
 <ref LargeTable>

LargeTable:
<bla>

Can this be done?

+2
source share
2 answers

You can use the SpecFlow keyword "background".

Background: 
    Given my table looks like
    | .... | .... |

. , , .

+1

Source: https://habr.com/ru/post/1613222/


All Articles