简体   繁体   English

Specflow中的表是否绑定到“步骤定义”或“功能文件”?

[英]Are tables in Specflow tied to Step Definitions or the Feature File?

I looked through the documentation of both Specflow and Cucumber and I couldn't find a definitive answer to this question. 我浏览了Specflow和Cucumber的文档,但找不到这个问题的明确答案。 Let's say for example I have a [Given] step with a table full of inputs like this : 比方说,例如,我有一个[Given]步骤,其中的表充满了这样的输入:

Given I login with a <pin> and it is a valid <user role>
| PIN    | User Role |
| 111111 | Admin     |
| 222222 | User      | 

My primary question is that if I reuse this step in other feature files do I have to recopy the table with each use or does the table travel with the globally accessed Step Definition? 我的主要问题是,如果我在其他功能文件中重复使用此步骤,是否每次使用都必须重新复制该表,或者该表是否随全局访问的“步骤定义”一起移动?

I am designing the Specflow solution for my company from the ground up and I am trying to stick to DRY as much as possible. 我正在从头开始为我的公司设计Specflow解决方案,并且我会尽量坚持DRY。 So laying a foundation of reusable shared steps is a high priority goal for me. 因此,为可重用的共享步骤奠定基础是我的首要任务。 I might be overthinking this question to where I can't see the forest because of the trees, but I like to have these kind of specifics laid out in plain language because it helps me learn better. 我可能会想过这个问题,以至于因为树木而看不到森林,但是我喜欢用通俗易懂的语言列出这些细节,因为它可以帮助我更好地学习。 So any help would be appreciated. 因此,任何帮助将不胜感激。

You don't need to copy if you using exactly the same step in another feature file. 如果在另一个功能文件中使用完全相同的步骤,则无需复制。 The same step definition is global across your feature file hence the data as well. 同一步骤定义在要素文件中是全局的,因此在数据中也是全局的。 Each step should be exactly same. 每个步骤应该完全相同。 If you change even a single letter in your step then you have to generate another step definition. 如果您在步骤中甚至更改了单个字母,则必须生成另一个步骤定义。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Specflow 特征文件不使用步骤定义 - Specflow features file not using step definitions Specflow 步骤文件似乎无法被功能文件识别 - Specflow step file doesn't appear to be recognised by feature file 在步骤定义中从SpecFlow功能文件获取路径 - Get the path from a SpecFlow feature file in a Step Definition 如何适应 specflow 步骤定义以使用一种方法从 specflow 特征文件中接受不同数量的参数 - How to accommodate specflow step definition to accept deferent number of parameters from specflow feature file with one method 带有页面对象模型的 Specflow 中的常见步骤定义 - Common Step Definitions in Specflow with Page Object Model SpecFlow可重复使用的步骤定义 - SpecFlow Re-usable step definitions Specflow,看不到步骤定义的建议代码 - Specflow, not seeing suggested code for Step Definitions "Specflow 测试步骤继承导致“不明确的步骤定义”" - Specflow test step inheritance causes "Ambiguous step definitions" Specflow-无法在功能文件之间共享步骤 - Specflow - Unable to share step between feature files 在Visual Studio 2010中使用specflow创建步骤定义文件时,生成的功能文件不清楚 - Creating the step definition file using specflow in visual studio 2010, the generated feature file is not clear
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM