Notes on Using Acceptance Test-Driven Development (ATDD) to Derive Test Cases
ISTQB Exam Preparation
1. Understanding ATDD
- Definition: ATDD is a collaborative practice where stakeholders, developers, and testers work together to define acceptance criteria (testable requirements) before development begins.
- Goal: Ensure the software meets business needs by writing acceptance tests first, which guide development and act as a shared specification.
- Key Difference from TDD:
- TDD focuses on unit tests (developer-level).
- ATDD focuses on acceptance tests (business/user-level).
2. Steps to Derive Test Cases Using ATDD
Step 1: Collaborate with Stakeholders
- Involve business analysts, testers, and developers to clarify requirements.
- Use user stories or acceptance criteria as the foundation.
Step 2: Define Acceptance Criteria
- Translate requirements into testable conditions (e.g., "The system must allow users to reset their password").
- Focus on functional and non-functional requirements (e.g., performance, security).
Step 3: Write Scenarios Using Gherkin Syntax (Given-When-Then)
Step 4: Identify All Scenarios
- Cover normal, edge, and error cases:
- Normal: Valid input (e.g., correct email for password reset).
- Edge: Boundary conditions (e.g., expired reset link).
- Error: Invalid input (e.g., non-existent email).
Step 5: Refine and Validate Test Cases
- Review test cases with the team to ensure they align with requirements and are clear, actionable, and testable.
- Use tools like Cucumber, SpecFlow, or JBehave to automate and execute tests.
3. Key Characteristics of ATDD Test Cases
- Business-Centric: Directly tied to user needs and business goals.
- Automatable: Designed for automation (e.g., using Gherkin syntax).
- Comprehensive: Covers all possible user paths and error conditions.
- Shared Understanding: Acts as a common language between stakeholders and developers.
4. Benefits of ATDD for Test Case Derivation
- Early Defect Detection: Identifies gaps in requirements before development.
- Improved Communication: Ensures everyone understands the requirements.
- Reduced Rework: Tests guide development, reducing rework later.
- Traceability: Test cases are directly linked to requirements.
5. Example Scenario
Requirement: "The system must allow users to reset their password."
Test Cases Derived via ATDD:
-
Valid Email:
- Given the user enters a valid email
- When they submit the password reset form
- Then the system sends a reset link to the email.
-
Invalid Email:
- Given the user enters an invalid email
- When they submit the password reset form
- Then the system displays an error message.
-
Expired Link:
- Given the user clicks an expired reset link
- When they attempt to set a new password
- Then the system displays an error message.
6. Tools for ATDD
- Cucumber (Java): Write tests in Gherkin.
- SpecFlow (C#): Similar to Cucumber for .NET.
- JBehave (Java): Framework for behavior-driven development.
7. ISTQB Relevance
- Key Concepts:
- Test Case Derivation from requirements.
- Collaboration between stakeholders.
- Behavior-Driven Development (BDD) techniques.
- Exam Focus: Understand how ATDD ensures test cases are aligned with business needs and testable.
Summary:
ATDD derives test cases by collaboratively defining acceptance criteria, structuring them into scenarios (e.g., GWT), and covering all possible user interactions. This ensures tests are testable, comprehensive, and aligned with business goals, improving software quality and reducing defects.