0
0
Testing Fundamentalstesting~20 mins

Behavior-driven development (BDD) concept in Testing Fundamentals - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
BDD Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding BDD Scenario Structure

Which of the following best describes the correct structure of a Behavior-driven development (BDD) scenario?

AGiven some initial context, Then an event occurs, When ensure some outcomes
BWhen some initial context, Given an event occurs, Then ensure some outcomes
CThen some initial context, Given an event occurs, When ensure some outcomes
DGiven some initial context, When an event occurs, Then ensure some outcomes
Attempts:
2 left
💡 Hint

Think about the natural flow of setting up context, performing an action, and checking results.

Predict Output
intermediate
2:00remaining
Output of a Simple BDD Test Result

Given the following BDD test result summary, what is the overall test status?

Testing Fundamentals
Feature: Login functionality
  Scenario: Successful login
    Given user is on login page
    When user enters valid credentials
    Then user is redirected to dashboard

Test result: Given passed, When passed, Then failed
AFail
BPass
CSkipped
DError
Attempts:
2 left
💡 Hint

All steps must pass for the scenario to pass.

assertion
advanced
2:00remaining
Correct Assertion in BDD Step Definition

Which assertion correctly verifies that a user is redirected to the dashboard page in a BDD step definition?

Testing Fundamentals
def then_user_redirected_to_dashboard():
    current_url = get_current_url()
Aassert current_url is None
Bassert current_url == '/dashboard'
Cassert '/dashboard' in current_url
Dassert current_url != '/dashboard'
Attempts:
2 left
💡 Hint

The URL should exactly match the dashboard path.

🔧 Debug
advanced
2:00remaining
Identify the Bug in BDD Step Implementation

What is the bug in this BDD step implementation?

Testing Fundamentals
from behave import given

@given('the user is logged in')
def step_impl(context):
    context.logged_in = True
    return True
AReturning True is unnecessary and may cause errors
BMissing context parameter in function
CDecorator @given is used incorrectly
Dcontext.logged_in should be set to False
Attempts:
2 left
💡 Hint

Check what step functions should return in behave framework.

framework
expert
2:00remaining
Choosing the Best BDD Framework for Python

Which Python BDD framework supports natural language feature files, integrates with pytest, and uses the Given-When-Then syntax?

ABehave
Bunittest
Cpytest-bdd
Dnose
Attempts:
2 left
💡 Hint

Look for a framework that combines pytest features with BDD style.