我想知道如何传递真或假参数。(config_type = True
( 使用 Python 语言中的行为。
Scenario Outline:
Given
upload xls with parameters "shop" xlsx (path: "./upload12.xlsx") definition named "config_short" and "<config_type>"
Examples:
| config_type|
| False |
@given('upload xls with parameters "sh" xlsx (path: "./upload12.xlsx") definition named "config_short" and "{config_type}"')
def step_impl(context, config_type)
definition = someMethod(xlsx_path, config_short, config_type=True)
这是在BDD中传递此类参数的正确方法吗?在下一个测试中,我想重用该someMethod
但要config_type = False
我认为你很接近,但需要将config_type参数传递给某个方法:
Scenario Outline:
Given upload xls with parameters "shop" xlsx (path: "./upload12.xlsx") definition named "config_short" and "<config_type>"
Examples:
| config_type|
| False |
@given('upload xls with parameters "sh" xlsx (path: "./upload12.xlsx") definition named "config_short" and "{config_type}"')
def step_impl(context, config_type):
definition = someMethod(xlsx_path, config_short, config_type=config_type)
也就是说,你可以用这样的东西来清理它:
功能文件:
Scenario Outline:
Given upload xls with parameters "<type>" xlsx (path: "<xls_path>") definition named "<config_name>" and "<config_type>"
Examples:
| type | xls_path | config_name | config_type|
| shop | ./upload12.xlsx | config_short | False |
步骤文件:
@given('upload xls with parameters "{type}" xlsx (path: "{xls_path}") definition named "{config_name}" and "{config_type}"')
def step_impl(context, type, xls_path, config_name, config_type):
definition = someMethod(xlsx_path=xls_path, config_short=config_short, config_type=config_type)