Test Automation & BDD: How They Fit Together

  November 13, 2019

Many development problems arise from miscommunication. For example, a developer may start working on a specification that they don't fully understand or a stakeholder may request a feature without understanding the implications. The result is rework that increases costs, creates delays and, in many cases, leads to failed software projects that go well over budget.

Behavior-driven development, or BDD, helps overcome these challenges by encouraging collaboration across roles. Rather than replacing the existing Agile process, BDD serves as a plugin that increases the likelihood of delivering on the promise of Agile — reliable and on-time releases of working software that meet the organization's evolving needs.

BDD helps you deliver on the promises of Agile development — reliable and on-time releases of working software that meets evolving specs.

Let's take a look at how BDD and test automation work together to improve the software development cycle.

What is BDD?

Behavior-driven development closes the gap between business and technical teams by encouraging collaboration across roles to build a shared understanding of a problem; working in small iterations to shorten the feedback loop; and, producing business-friendly documentation that is automatically checked against the system's behavior.

There are three core steps to the process

  • Take a small upcoming change, such as a user story, and collaboratively create concrete examples of the new functionality to Discover the precise scope of the problem being addressed. The outcome is a detailed, shared understanding of what should be delivered.
  • Formulate the concrete examples in a way that can be automated to ensure the functionality exists. Often, these examples are documented in Gherkin feature files that consist of Given-When-Then scenarios. These feature files are easy for anyone to understand, even if they’re not technical.
  • Write code to automate the behavior described in each scenario. The resulting automated test is then used to guide code development. 

The most important part of the BDD process is Discovery, a regular workshop where a minimum of three perspectives must be represented: stakeholder, test engineer, developer. At this short, frequent workshop a shared understanding of the requirement is reached through the use of concrete examples. A common meeting format is known as example mapping

The biggest mistake that development teams make with adopting BDD is assuming that it's just another test. Without the conversations across the business and technical teams, these tests won't address the miscommunication that results in projects being delayed and running over budget. 

How Test Automation Fits

Most development teams are familiar with test automation through test-driven development (TDD). For example, developers may write unit tests and test engineers may write integration tests that are automatically executed as part of the build process before each commit or deploy. Any issues are flagged for developers to address before they reach production.

The BDD practices work in conjunction with TDD. Before pulling a user story into development and beginning the TDD process, the team applies the BDD practices to Reine the requirements, generate concrete examples, formulate them as business-readable specification, and automate them to create living documentation. These specifications run alongside TDD tests on a continuous integration servers like Jenkins

Here's how a typical development process might work:

  1. The team comes up with a user story.
  2. In a discovery workshop, stakeholders, test engineers, and developers create concrete examples that illustrate the expected behavior of the system.
  3. The concrete examples are formulated into Gherkin-based documentation.
  4. The Gherkin-based documentation is automated to create living documentation.
  5. The delivery team pull the user story and begin to write unit tests and features, and build integration tests.
  6. When the user story is finished, the CI build ensures that all unit and integration tests pass, as well as the Gherkin BDD tests that ensure the business case is met. 

The living documentation generated by applying BDD practices has another benefit. Since Gherkin is written in plain English, stakeholders can easily see what features are passing and what features are still in development or deprecated. These capabilities make it easy for everyone to stay on the same page without having to manually update documentation with each product increment.

Full Circle With TestComplete and HipTest

There are a couple of challenges that development teams face when implementing behavior-driven development — both in terms of communication and integration.

A common challenge for interdepartmental teams is collaborating and organizing feature files. For example, if feature files are stored in source control, how can stakeholders view them? How can stakeholders instantly understand what features are implemented and working?

HipTest solves this problem by providing a web-based interface for business and technical teams to define business goals and requirements. After the feature files are ready, HipTest Publisher makes it easy to export them as step definitions that can be incorporated into an automated test suite. You can even generate customizable reports.

1911_Test-Automation-and-BDD_hiptest.png

Another challenge is managing your living documentation alongside the rest of your test suite, while continuing to deliver actionable reports to the relevant stakeholders. 

TestComplete simplifies the process with native support for Gherkin's Given-When-Then scenarios. There's no need to build and maintain complex technology stacks spanning multiple different tools — you can easily convert feature files into automated tests without any additional plugins and sync in real-time with HipTest. To learn more, check out our documentation

1911_Test-Automation-and-BDD_tc.png

It’s also easy to share reports with stakeholders. TestComplete's Zephyr for Jira integration make it easy to share BDD insights with business teams without technical teams having to generate and email reports regularly. There's a single interface where everyone can view the status of tests and related bug reports using the wider Jira ecosystem.

1911_Test-Automation-and-BDD_ht-tc-(1).png

In addition to creating BDD scenarios, TestComplete makes it easy to build automated UI functional tests with its industry-leading record and playback functionality, reporting features and CI/CD integrations. Test engineers can easily use BDD to minimize miscommunications and integration tests to ensure that all of the pieces fit together before a deploy.

The Bottom Line

Behavior-driven development helps improve communication between business and technical teams. Using HipTest and TestComplete, you can simplify the process by collaborating on the same platform and incorporating BDD living documentation into the rest of your test suite. 

Start your free trial of TestComplete to learn more about how TestComplete can simplify your testing processes.