Behavior-driven development, or BDD, is a trend much spoken about recently. In short, this methodology provides a set of best practices to translate natural language sentences into executable, yet easily readable tests.<\/p>\n\n\n\n
In this article I want to focus on the benefits and limitations of the BDD approach.<\/p>\n\n\n\n
What is BDD<\/strong><\/p>\n\n\n\n
BDD\u2019s primary purpose is to provide a common understanding of project features for all the stakeholders and eliminate ambiguities from requirements. In other words, this approach helps to describe the user\u2019s needs and the system\u2019s expected behavior.<\/p>\n\n\n\n
The following two examples demonstrate the difference between BDD and the traditional functional approach.<\/p>\n\n\n\n
A simple BDD test scenario:<\/p>\n\n\n\n
Scenario: User can log in to the web application\n Given I have opened web application \"app.com\"\n And I am on the login page\n When I type \"User\" credentials\n And I submit the form\n Then I should be redirected to the home page<\/code><\/pre>\n\n\n\nThe code implemented with traditional functional approach:<\/p>\n\n\n\n
LoginPage loginPage = new LoginPage()\nloginPage.login(\u2018User\u2019)\nMainPage mainPage = loginPage.submitForm()\nmainPage.verifyPage()<\/code><\/pre>\n\n\n\nFrom the example, we can clearly see that a BDD test example is more readable and allows everybody from the project team to understand what function or requirement the test aims to verify. In terms of Agile, we can clearly define what feature, user story, and acceptance criteria is covered by each automation script. Naturally, writing BDD test scenarios requires some more efforts.<\/p>\n\n\n\n
BDD vs. traditional functional tests<\/strong>
Let\u2019s compare the traditional approach to test implementation with the BDD on the example of Cucumber, a tool to create executable specifications.\/api\/v1\/uploads\/44890\/^712B7142FFEA76B33C4EDDD52F20F30BBFDCF351832386D61C^pimgpsh_fullsize_distr.png<\/a><\/p>\n\n\n\n
Feature: Test User API\n Scenario: Get all users\n Given url 'some-api.com\/api\/users'\n When method GET\n Then status 200\n And assert response.length == 2\n And match response[0].name == 'FirstUser'<\/code><\/pre>\n\n\n\nWhat you get with BDD testing<\/strong>
Aside from the improved readability of scripts that can be reached with BDD, this approach can dramatically increase visibility and clarity on the project. Also, it can save time on long-term projects. From my experience, one of the major pains of a project is that only the engineer who implemented the tests can interpret their results in a correct way. BDD makes reports understandable for everyone, including managers, analysts, and clients.<\/p>\n\n\n\n
Certainly, test implementation is not the central activity on the project. Usually test execution and support take much more time than writing all the tests. If you calculate the efforts spent on issue investigation and test results analysis, you can see that troubleshooting of failed BDD scenarios is very fast. You can easily detect what step of what feature has failed and why. Accordingly, you can establish a relationship between a failed test and a corresponding business requirement. After that, you can provide feedback to stakeholders and answer the questions about what features do not work as expected and what functions are end-user ready.<\/p>\n\n\n\n
A few more things to consider<\/strong>
Although BDD testing has a lot of benefits, there are some limitations you might want to consider while choosing a methodology for your project:<\/p>\n\n\n\n
- You will dedicate considerable amounts of time and effort to the implementation of the code. For small, fast-paced projects, the wordy BDD approach is redundant. Consider using BDD if the development will cover multiple product features and complex user interactions and will last longer than six months.<\/li>
- To set up effective BDD workflows, you must have your project requirements strictly defined. If they are not, expect to spend extra time on clarifying app workflows and behaviors.<\/li>
- Sometimes, the step definitions (Given\/When\/Then) may seem hard to navigate. To make things easier, you can use IDE plugins, like VSCode Cucumber, that open the code behind the steps or help to autocomplete them.<\/li><\/ul>\n\n\n\n
Summary<\/strong>
BDD is not a silver bullet, but like any other technology or approach it can add up to the success of the appropriate projects.
If you agree with most of the affirmations below, you should really consider implementing BDD:<\/p>\n\n\n\n
- My project has clear and well-defined business requirements;<\/li>
- On a regular basis, I need to share clear results of the project\u2019s progress with all team members, stakeholders, and management;<\/li>
- My project will last longer than six months;<\/li>
- I plan to use a data-driven testing approach.<\/li>
https:\/\/www.utest.com\/articles\/are-the-benefits-of-bdd-worth-the-effort<\/a> <\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"Behavior-driven development, or BDD, is a trend much spoken about recently. In short, this methodology provides a set of best practices to translate natural language sentences into executable, yet easily readable tests. In this article I want to focus on the benefits …. Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"pagelayer_contact_templates":[],"_pagelayer_content":"","_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"class_list":["post-85","page","type-page","status-publish","hentry"],"yoast_head":"\nAre the Benefits of BDD Worth the Effort? • BDD Testing<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.bddtesting.com\/are-the-benefits-of-bdd-worth-the-effort\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Are the Benefits of BDD Worth the Effort? • BDD Testing\" \/>\n<meta property=\"og:description\" content=\"Behavior-driven development, or BDD, is a trend much spoken about recently. In short, this methodology provides a set of best practices to translate natural language sentences into executable, yet easily readable tests. In this article I want to focus on the benefits .... Read More\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.bddtesting.com\/are-the-benefits-of-bdd-worth-the-effort\/\" \/>\n<meta property=\"og:site_name\" content=\"BDD Testing\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.bddtesting.com\/are-the-benefits-of-bdd-worth-the-effort\/\",\"url\":\"https:\/\/www.bddtesting.com\/are-the-benefits-of-bdd-worth-the-effort\/\",\"name\":\"Are the Benefits of BDD Worth the Effort? • BDD Testing\",\"isPartOf\":{\"@id\":\"https:\/\/www.bddtesting.com\/#website\"},\"datePublished\":\"2019-06-17T19:26:42+00:00\",\"dateModified\":\"2019-06-17T19:26:42+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.bddtesting.com\/are-the-benefits-of-bdd-worth-the-effort\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.bddtesting.com\/are-the-benefits-of-bdd-worth-the-effort\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.bddtesting.com\/are-the-benefits-of-bdd-worth-the-effort\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.bddtesting.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Are the Benefits of BDD Worth the Effort?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.bddtesting.com\/#website\",\"url\":\"https:\/\/www.bddtesting.com\/\",\"name\":\"BDD Testing\",\"description\":\"Behavior-driven development testing\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.bddtesting.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Are the Benefits of BDD Worth the Effort? • BDD Testing","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.bddtesting.com\/are-the-benefits-of-bdd-worth-the-effort\/","og_locale":"en_US","og_type":"article","og_title":"Are the Benefits of BDD Worth the Effort? • BDD Testing","og_description":"Behavior-driven development, or BDD, is a trend much spoken about recently. In short, this methodology provides a set of best practices to translate natural language sentences into executable, yet easily readable tests. In this article I want to focus on the benefits .... Read More","og_url":"https:\/\/www.bddtesting.com\/are-the-benefits-of-bdd-worth-the-effort\/","og_site_name":"BDD Testing","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.bddtesting.com\/are-the-benefits-of-bdd-worth-the-effort\/","url":"https:\/\/www.bddtesting.com\/are-the-benefits-of-bdd-worth-the-effort\/","name":"Are the Benefits of BDD Worth the Effort? • BDD Testing","isPartOf":{"@id":"https:\/\/www.bddtesting.com\/#website"},"datePublished":"2019-06-17T19:26:42+00:00","dateModified":"2019-06-17T19:26:42+00:00","breadcrumb":{"@id":"https:\/\/www.bddtesting.com\/are-the-benefits-of-bdd-worth-the-effort\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.bddtesting.com\/are-the-benefits-of-bdd-worth-the-effort\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.bddtesting.com\/are-the-benefits-of-bdd-worth-the-effort\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.bddtesting.com\/"},{"@type":"ListItem","position":2,"name":"Are the Benefits of BDD Worth the Effort?"}]},{"@type":"WebSite","@id":"https:\/\/www.bddtesting.com\/#website","url":"https:\/\/www.bddtesting.com\/","name":"BDD Testing","description":"Behavior-driven development testing","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.bddtesting.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.bddtesting.com\/wp-json\/wp\/v2\/pages\/85"}],"collection":[{"href":"https:\/\/www.bddtesting.com\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.bddtesting.com\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.bddtesting.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bddtesting.com\/wp-json\/wp\/v2\/comments?post=85"}],"version-history":[{"count":1,"href":"https:\/\/www.bddtesting.com\/wp-json\/wp\/v2\/pages\/85\/revisions"}],"predecessor-version":[{"id":86,"href":"https:\/\/www.bddtesting.com\/wp-json\/wp\/v2\/pages\/85\/revisions\/86"}],"wp:attachment":[{"href":"https:\/\/www.bddtesting.com\/wp-json\/wp\/v2\/media?parent=85"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}