2

I wonder how to pass True or False arguments such like. (config_type = True) using behave in python language.

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)

Is that a proper way to pass such arguments in BDD? In next test I want to reuse that someMethod but with config_type = False

1 Answer 1

1

I think you are close, but need to pass the config_type parm through to someMethod:

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)

That said, you could probably clean that up overall with something like this:

Feature file:

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    |

step file:

@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)
Sign up to request clarification or add additional context in comments.

1 Comment

python passes 'True' like True but when 'False' then also True so need to add this code in my TC ``` if config_type == "True": config_type= True else: config_type = False

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.