Feature: UsersScenario: Add users Given the following users | name | email | password | | Alice | alice@example.com | secret | | Bob | bob@example.com | password |When I enter the email "alice@example.com"Then the user should be in the list
touch features/steps/steps.py
frombehaveimport*@given('the following users')defstep_impl(context):forrowincontext.table:name=row['name']email=row['email']password=row['password']context.users.append({'name':name,'email':email,'password':password})@when('I enter the email "{email}"')defstep_impl(context,email):context.email=email@then('the user should be in the list')defstep_impl(context):foruserincontext.users:ifuser['email']==context.email:returnassertFalse,f"User with email '{context.email}' not found"
Feature: GreetingScenario: Greet the user by name When I enter the name "Alice"Then the greeting should say "Hello, Alice!"Scenario: Greet the user with a different name When I enter the name "Bob"Then the greeting should say "Hello, Bob!"
frombehaveimport*@when('I enter the name "{name}"')defstep_impl(context,name):context.name=name@then('the greeting should say "{greeting}"')defstep_impl(context,greeting):assertf"Hello, {context.name}!"==greeting