The Wayback Machine - https://web.archive.org/web/20240705194248/https://www.geeksforgeeks.org/agile-testing-methods-behavior-driven-testing/
Open In App

Agile testing methods – Behavior Driven Testing

Last Updated : 21 Sep, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

Agile testing is a relatively newer approach to

software testing

It follows the principles of agile software development as called out in the Agile Manifesto. About 10-12 years back, most of the projects were run in Waterfall fashion. However, With the basic advantage of quicker time to market, Agile methodology is gaining popularity nowadays.

nowadays

In Agile, software development and testing are continuous, and it is a collaborative effort between testers, developers, product owners, and even customers testing is not a separate phase like the waterfall model.

The difference with Agile methodology is that the testing starts at the very start of the project, even before development has started, and gives continuous feedback to the development activity.

Also, as a thought process also, testing in agile methodology is different since the onus of quality lies with everyone in the Agile team and not just QA i.e. in a way everyone on the team is responsible for testing.

Agile Testing Methods :
1. Test Driven Development (TDD) :

  • The term TDD was coined by Kent Beck in 2002
  • In this methodology, Tests are written before functions.
  • It relies on the repetition of a very short development cycle
  • First, the developer writes an initially failing automated test case that defines a desired improvement or new function
  • Second, the Developer produces the minimum amount of code to pass that test, and
  • Finally the new code to acceptable standards

The idea behind Test-driven development is to make each change small enough to iterate rapidly. As you automate and implement each feature or a change you’ve basically added something valuable to your overall system, and you’re ready for a shippable product and product owner feedback.

(a). Behavior-driven, testing (BDD) :

  • It was first described by Dan North in 2009.
  • BDD is an extension of test-driven development (TDD).
  • Product Owner, Programmer, and Tester (3 amigos) are involved from the very start.
  • Aids in application implementation from a stakeholder point of view through the use of the given-when-then style of representing tests.
  • BDD Shifts the vocabulary from being test-based to behavior-based.
  • It May be interchangeably/loosely called
    • Storytelling
    • Functional Testing
    • Acceptance Test Driven Development (ATDD)

Since BDD involves thinking in a common language, It helps teams to have the right conversations at the right time and thus maximizing the amount of valuable code produced. It also has the potential to identify gaps in understanding and areas where we need more information before we know what is to be done. 

2. Steps involved in the BDD Test :

  • First, take a small upcoming change to the system i.e. a User Story or a scenario (Also known as Example in Context of Cucumber).
  • Analyze new functionality to explore and agree on the details of what’s expected to be done by discussing between three amigos – BA, developer, and tester.
  • Document the scenarios in a way that can be automated.
  • Lastly, implement the behavior described by each documented example, starting with an automated test to guide the development of the code.

A practical BDD project flow is described in the figure below. 

3. BDD vs ATDD vs TDD : Key differences
Behavior Driven Development (BDD) :

  • More customer-oriented and helps developers write tests keeping in mind the behavior desired by the stakeholders, and not tests to verify the code implementation.
  • Customer-focused and uses English-like language, allowing easier collaboration with non-technical stakeholders.
  • Gives a clear understanding as to what the system should do from the perspective of the developer and the customer.
  • In BDD tests fail because the feature hasn’t been developed,
    • The feature is based on what customer needs

Acceptance Test Driven Development (ATDD) :
 

  • Starts by guiding the development team on what features are actually required to be built and then testing those features to verify their functionality. Hence, ATDD focuses at a high level and TDD at a low level.
  • Do the right thing (Business Point of  View).
  • Gives the developer an understanding of what the system should do.
  • Recent ATDD tools are inclining more towards using BDD-like language of Given, When, Then.

Test Driven Development (TDD)

  • Tells the developer whether her/his code works fine.
  • Do things right (Dev Point of  View).
  • In TDD tests fail because the algorithm/function hasn’t been developed.
    • The algorithm is based on what the programmer knows
       

General Process Flow in BDD/TDD

4. Cucumber and Gherkins :
Cucumber :

  • An important point to note is that Cucumber is not a Testing tool.
  • Cucumber is a tool based on the Behavior Driven Development (BDD) framework which is used to write User acceptance tests.
  • Cucumber reads executable specifications written in English text and validates that the software does what the specifications suggest.
  • Scenarios or Specifications for Cucumber are written in below format :

Scenario : <Detailed scenario description>

GivenThe most: This clause describes the pre conditions

When : This clause defines the trigger point or an operation.

Then : This clause defines the outcome of the event or the operation. 

Gherkins :

  • Gherkin is a Business Readable, Domain Specific Language.
  • It is simple to understand as it removes logic and syntax details from behavior tests.
  • It uses a set of Keywords to make tests more understandable. The most commonly used keywords are Feature, Given, When, The, Rule, and many more.
  • Gherkins has been translated into and can be used in multiple languages. This helps easy communication between Stakeholders and business users.

Advantages and Disadvantages :

  • Tests written in Gherkins/Cucumber serve the dual purpose of tests and project documentation.
  • Adopting the BDD approach ensures a development process is built with the user experience in mind.
  • This methodology requires a lot of engagement among 3 amigos. This can serve as an advantage or disadvantage depending on the project situation.

Closing thoughts :
The BDD approach can be a good choice when you need everyone on the team to be engaged without digging into technical aspects. Also, this approach is not ideal for all project types. Shorter projects may get delayed using this method. It can also make projects complicated and sometimes slow them down. It also requires a major mindset shift from the traditional way of working.
 



Similar Reads

Difference between Data Driven Testing and Keyword Driven Testing
1. Data-Driven Testing :Data-driven testing or DDT is also named Parameterized testing. DDT is a process of testing software that is used to test the computer Software by applying some conditions like verified inputs. For testing the software various methods are used and every methodology differs from the other for maintaining accuracy. DDT focuses
4 min read
What is Behavior-Driven Development (BDD)?
Behavior-driven development (BDD) is an agile software development methodology that prioritizes collaboration among developers, testers, and non-technical stakeholders to ensure customer-centric outcomes. In BDD, requirements are defined in terms of desired behaviors and user stories, enabling clearer communication and a focus on delivering busines
10 min read
What is Code Driven Testing in Software Testing?
Prerequisite - TDD (Test Driven Testing) Code Driven Testing is a software development approach in which it uses testing frameworks that allows the execution of unit tests to determine whether various sections of the code are acting accordingly as expected under various conditions. That is, in Code Driven Testing test cases are developed to specify
2 min read
Data Driven Testing in Software Testing
Prerequisite: Software Testing Data-Driven Testing is a type of software testing methodology or more exactly approach to the architecture of automated tests by creating test scripts and reading data from data files.  In this type, the data files involved are Data pools, CSV files, Excel files, ADO objects, ODBC sources, etc. The testing functions c
4 min read
Keyword Driven Testing in Software Testing
The keyword-driven testing is based upon a keyword-driven framework that defines functional automation testing and is categorized into four different parts test steps for test cases, objects, actions, and data sets. What is Keyword Driven Testing?It is a software engineering technique or approach that is used in functional automation testing that's
4 min read
Difference between Agile Testing and Waterfall Testing
Agile Testing: Agile Testing is a type of software testing that involves all members of the project team, special experts and testers. In agile testing, testing is not a different phase and testing is performed along with development phases that includes requirements, design, coding and generation of test cases.Agile testing takes place alongside t
2 min read
Difference between Agile Testing and V-Model Testing
1. Agile Testing : Agile Testing is the type of software testing that involves all members of the project team, special experts and testers. In agile testing work together, testing is not a different phase and testing is performed along with development phases that includes requirements, design, coding and generation of test cases. It takes place a
3 min read
Difference between Agile and Scrum Testing
Agile Testing: Agile testing is a type of software testing that is performed alongside the software development. It is the part of Agile Software Development in which the development and the testing process goes side by side. When in software development life cycle development and the testing goes parallel way then it is known as agile development
2 min read
Agile Testing Quadrants
Agile testing quadrants is consider to be a tool or a manual, designed by the Brain Marick, which divides the whole agile testing methodology into four basic quadrants. Agile Testing Quadrants help the whole team to communicate and deliver a high quality product in no time. With the help of Agile Testing Quadrants the whole testing process can be e
3 min read
Organizational Behavior - Role of Managers
What is Organizational Behavior?Organizational behavior just as the name states, is the process of understanding and managing human behavior within an organization. An organization not only runs on profits, work and schedules but also takes into consideration the human values. Organization have come up with a theory that the organization runs well
4 min read