简体   繁体   中英

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?

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 | simple@example.com |

The json file looks like this:

{ 
  "E-mail addresses": {
    "Valid" :{
      "Simple": "email@domain.com",
      "Dot in the address": "firstname.lastname@domain.com"
    }
  }
}

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+

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM