命名 Cucumber 的数据 Table
Naming Cucumber's Data Table
我在可能包含 50 多个参数的表单上创建测试用例,其中一些参数会在具体回答一组特定问题时显示。
数据 table 变得很长,所以我将它们分成多个数据 table,每个数据用于特定的表单部分。
我不想在步骤中添加每个标题,所以我想改用数据 table 的名称。
而不是:
Scenario:
.
.
.
When I fill in <title> <first name> <surname> ...
|title|first name|surname|...|
.
.
.
我要:
When I fill in <personal details>
And "personal details":
|title|first name|surname|...|
.
.
.
是否可以添加并使用数据 table 的名称作为占位符?
注意:我正在使用 Behave 和 Python。
我不确定你在问什么,但如果你在不同的场景中使用相同的细节,那么最好使用 Cucumber 的 Background
选项。以便在执行每个场景之前对其进行检查。
使用 <> 语法是绝对不可能的。
如果您没有很多行,并且您主要关心的是非常宽的 table 的可读性,那么一个选项可能是 "transposing" table,如下所示:
When I fill in the personal details
| Field | Value |
| Title | Prof. |
| Surname | Einstein |
| ... | |
另一种选择是在后台定义重复出现的属性集,如下所示:
Background:
Given the personal details for 'minimal personal details'
| Surname | First name |
| Doe | John |
And the personal details for 'insufficient personal details'
| First name |
| Jack |
And the personal details for 'all personal details'
...
...
When I fill in personal details using 'insufficient personal details'
后台绑定在上下文中注册它们的数据,'when'绑定使用上下文中的数据。
无论哪种情况,您都需要一个能够容忍缺失属性并捕获未知属性的绑定。
Gherkin 中的 Tables 是真实数据的视图(意味着列的子集和感兴趣的行)。出于可读性原因(并且有人理解您在做什么),您最多应该有 7 (plus/minus 2) 列。也许,剩余的数据可以从配置文件或配置文件数据库中注入?!?您基本上使用提供的 Table 列作为键,以便能够 select 配置行并从配置文件中检索剩余数据。
我在可能包含 50 多个参数的表单上创建测试用例,其中一些参数会在具体回答一组特定问题时显示。
数据 table 变得很长,所以我将它们分成多个数据 table,每个数据用于特定的表单部分。
我不想在步骤中添加每个标题,所以我想改用数据 table 的名称。
而不是:
Scenario:
.
.
.
When I fill in <title> <first name> <surname> ...
|title|first name|surname|...|
.
.
.
我要:
When I fill in <personal details>
And "personal details":
|title|first name|surname|...|
.
.
.
是否可以添加并使用数据 table 的名称作为占位符?
注意:我正在使用 Behave 和 Python。
我不确定你在问什么,但如果你在不同的场景中使用相同的细节,那么最好使用 Cucumber 的 Background
选项。以便在执行每个场景之前对其进行检查。
使用 <> 语法是绝对不可能的。
如果您没有很多行,并且您主要关心的是非常宽的 table 的可读性,那么一个选项可能是 "transposing" table,如下所示:
When I fill in the personal details
| Field | Value |
| Title | Prof. |
| Surname | Einstein |
| ... | |
另一种选择是在后台定义重复出现的属性集,如下所示:
Background:
Given the personal details for 'minimal personal details'
| Surname | First name |
| Doe | John |
And the personal details for 'insufficient personal details'
| First name |
| Jack |
And the personal details for 'all personal details'
...
...
When I fill in personal details using 'insufficient personal details'
后台绑定在上下文中注册它们的数据,'when'绑定使用上下文中的数据。
无论哪种情况,您都需要一个能够容忍缺失属性并捕获未知属性的绑定。
Tables 是真实数据的视图(意味着列的子集和感兴趣的行)。出于可读性原因(并且有人理解您在做什么),您最多应该有 7 (plus/minus 2) 列。也许,剩余的数据可以从配置文件或配置文件数据库中注入?!?您基本上使用提供的 Table 列作为键,以便能够 select 配置行并从配置文件中检索剩余数据。