Specflow-使用功能文件中外部文件中的数据

问题描述

我正在使用SpecFlow进行测试,并在我的功能文件中寻找一种使用excel / csv / json中的inupt数据的方法。我准备使用SpecFlow + Excel,但与我正在使用的.NETCore和SpecFlow 3.3.57不兼容。 我也尝试使用Itamaram.Excel.SpecFlowPlugin,但是它也没有用。 https://github.com/Itamaram/SpecFlow.Plugin.Base 是否可以从外部文件读取输入数据并将其写入我的功能文件

解决方法

我们有一个新插件,可从json文件获取外部数据。

这是一个简单的SpecFlow插件,您可以将其安装为NuGet package

用法示例:

@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] |

json文件如下:

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

有关它的更多详细信息,请参见博客文章:https://specflow.org/blog/new-plugin-externaldata-helps-you-improve-test-coverage-quickly/


完全公开:我是SpecFlow和SpecFlow +的社区经理