-
Hi, is it possible to create a step definition that can contain an optional field and such that returns a boolean, true if the field is present and false if not? For example: @step("I {optional_field:bool} post something")
def step_impl(context, optional_field):
... When I post something would result in When I successfully post something would result in POSSIBLE SOLUTION: @step("I {success} post something")
@step("I post something")
def step_impl(context, success=None):
optional_field = False
if success == "successfully":
optional_field = True but this is not really robust, because if I write the step: When I try to post something it will match the step above. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You can use optional types by using special registered types (simplified by using the NOTES:
SEE: |
Beta Was this translation helpful? Give feedback.
You can use optional types by using special registered types (simplified by using the
parse_type
module).NOTES:
{number:Number?}
for an optional number using thecfparse
matcher. It automatically implicitly generates patterns for other cardinalities by using the registered types/patterns with cardinality=1.SEE: