Specflow-在要素文件中使用外部文件中的数据 [英] Specflow - using data from external file in feature file

查看:86
本文介绍了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 | simple@example.com |

json文件如下所示:

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

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


全面披露:我是specFlow和specFlow+的社区经理

这篇关于Specflow-在要素文件中使用外部文件中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆