Skip to content

Enumerations in step definition - custom Exception #941

Closed Answered by jenisys
tamtadam asked this question in Q&A
Discussion options

You must be logged in to vote

All of the examples only match the known values and not the unknown ones (else/otherwise case).
In your case, the problem was that feature file writer has used an "invalid step".
You can check for these kind of problems with: behave --dry-run (detects undefined steps without paying the runtime costs)

POSSIBLE SOLUTIONS (at runtime):

  • Add another step-definition after the one for the Enum/Choices that matches the otherwise case
  • Use parse_type Variant to handle the otherwise case

EXAMPLE FOR SOLUTION 1:

@step("Choose from Choices: {param:Choices}")
def step_choices(ctx, param):
    # -- CASE: Valid Choices values
    pass

@step("Choose from Choices: {param}")  # OR: {param:w} that only on…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by jenisys
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants