可以有一个包含空值的场景大纲表吗? [英] Is it possible to have a scenario outline table with empty values?

查看:66
本文介绍了可以有一个包含空值的场景大纲表吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

场景大纲:废话连篇 当我在输入字段中输入和时 那么一切都很好

示例:
|a|b|
|1|2|
| ; ;|3|

上述方案在BBD行为中引发以下错误 测试未定义 请定义测试

我不确定我如何才能解决这个问题。 有什么建议吗?

推荐答案

使用https://pypi.org/project/parse/

中介绍的Custom Type Conversions
import parse

from behave import given, register_type


@parse.with_pattern(r'.*')
def parse_nullable_string(text):
    return text


register_type(NullableString=parse_nullable_string)

@given('params "{a:NullableString}" and "{b:NullableString}"'
def set_params(context, a, b):
  # a or b will be empty if they are blank in the Examples
  context.a = a
  context.b = b

现在功能文件可能如下所示

Given params "<a>" and "<b>"
# Rest of the steps
Examples:
 | a | b |
 | 1 | 2 |
 |   | 3 |

这篇关于可以有一个包含空值的场景大纲表吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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