Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Behavior-Driven Development | Additional Design Approaches
Software Architecture Fundamentals
course content

Conteúdo do Curso

Software Architecture Fundamentals

Software Architecture Fundamentals

1. Introduction to System Design
2. High Level Design
3. Low Level Design
4. Additional Design Approaches

bookBehavior-Driven Development

After understanding how Test-Driven Development (TDD) emphasizes writing tests before code, we're ready to dive into Behavior-Driven Development (BDD), a methodology that expands on TDD by involving stakeholders more directly in the testing and development process.

Behavior-Driven Development is a software development methodology that prioritizes the behaviors and features that the user expects, transforming them into testable specifications. Rather than writing technical test cases first, BDD encourages us to capture these behaviors in a more natural, user-friendly language, often called "user stories" or "scenarios".

Key Concepts of BDD

Gherkin syntax is central to BDD, allowing teams to write scenarios in a structured, understandable way. The basic format is:

  • Given: initial context or starting condition;
  • When: the action or behavior performed;
  • Then: the expected outcome or response.

For example, we can consider scenario of adding an item to the cart in e-commence platform:

Here Given sets the initial condition that the customer is viewing a product. When specifies the action, i.e., clicking on "Add to Cart." Then defines the expected outcome, which includes both the addition of the product to the cart and the correct item count on the cart icon.

BDD vs TDD

Example

Let's try to model several processes in e-commence platform using BDD approach.

User Login

BDD scenarios for login cover various user interactions with the login functionality, verifying both success and error handling. Example scenarios include:

Successful Login

Incorrect Password Warning

Locked Account After Multiple Failed Attempts

Product Search

BDD scenarios for search functionalities help users locate products effectively, catering to various search methods and ensuring a smooth browsing experience.

Search by Keyword

Filter by Category and Price Range

Checkout Process

The checkout process involves multiple steps, each of which can be tested to ensure users experience a smooth transaction.

Apply Discount Code

Shipping Option Selection

BDD scenarios for these core functionalities contribute to enhanced testing coverage and collaboration between business and development teams, ensuring features are designed to meet user expectations.

Which of the following scenarios best demonstrates a BDD example for login functionality?

Which of the following scenarios best demonstrates a BDD example for login functionality?

Selecione a resposta correta

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 4. Capítulo 2
some-alt