命名黄瓜的数据表 [英] Naming Cucumber's Data Table

查看:97
本文介绍了命名黄瓜的数据表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在包含50多个参数的表单上创建测试用例,其中的某些会在特定问题集得到具体回答时显示.

I am creating test cases on forms that could contains over 50 parameters, some of them would show up when a certain set of questions would be answered specifically.

数据表越来越长,所以我将它们分为多个数据表,每个数据表用于表单的特定部分.

The data tables were getting very long so I broke them into multiple data tables, each for a specific section of form.

我不想在步骤中添加每个标题,所以我想改用数据表的名称.

I don't want to add every heading in the step so I want to use the data table's name instead.

代替:

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|...|
   .
   .
   .

是否可以添加并使用数据表的名称作为占位符?

Is it possible to add and use the data table's name as the placeholder?

注意:我正在使用Behave和Python.

Note: I am working with Behave and Python.

推荐答案

使用<>语法绝对不可能.

It's definitely not possible using the <> syntax.

如果您没有很多行,而您主要关心的是非常宽的表的可读性,那么一个选项可能是转置"表,如下所示:

If you don't have many rows and your main concern is the readability of very wide tables then one option might be "transposing" the table like this:

When I fill in the personal details
    | Field    | Value    |
    | Title    | Prof.    |
    | Surname  | Einstein |
    | ...      |          |

另一个选择可能是在背景中定义重复出现的属性集,如下所示:

An other option could be to define the recurring set of properties in the Background like this:

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'

后台绑定在上下文中注册其数据,而何时"绑定使用上下文中的数据.

The bindings of the background register their data in the context and the 'when' binding uses the data from the context.

无论哪种情况,您都需要一个可以容忍缺失属性并捕获未知属性的绑定.

In either case, you'll need a binding that will tolerate missing properties and catch unknown ones.

这篇关于命名黄瓜的数据表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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