MichalG
MichalG

Reputation: 371

Specflow - using data from external file in feature file

I am using SpecFlow for my test and looking for a way to using inupt data from excel/csv/json in my feature file. I am treed to use SpecFlow+ Excel but it's not compatible with .NETCore and SpecFlow 3.3.57 which I am using. I also tried to use Itamaram.Excel.SpecFlowPlugin but it also didn't work. https://github.com/Itamaram/SpecFlow.Plugin.Base Is it any way to read input data from external file and write it to my feature file?

Upvotes: 1

Views: 3358

Answers (2)

user3312858
user3312858

Reputation: 1

External data don't work with SpecFlow 3.6 version (problem with build application: error Missing generator plugin). External data works on 3.9 version but this version have problem with AfterScenario hooks. All steps passed but finaly test failed (collection was modified; enumeration operation may not execute)

Upvotes: 0

Andreas Willich
Andreas Willich

Reputation: 5825

We have a new plugin to get external data from json files.

It is a simple SpecFlow plugin that you can install as a NuGet package.

Example of usage:

@property:email=E-mail_addresses.Valid
Scenario Outline: recording user information on successful registration

Given a visitor registering as "Mike Scott" with email <email>
When the registration completes
Then the account system should record <email> related to user "Mike Scott"

Examples: key examples
  | Variant            | email              |
  | simple valid email | [email protected] |

The json file looks like this:

{ 
  "E-mail addresses": {
    "Valid" :{
      "Simple": "[email protected]",
      "Dot in the address": "[email protected]"
    }
  }
}

More details are in the blog post about it: https://specflow.org/blog/new-plugin-externaldata-helps-you-improve-test-coverage-quickly/


Full disclosure: I am the community manager of SpecFlow and SpecFlow+

Upvotes: 1

Related Questions