December 1, 2019

What is the use of Behavior Driven Development (BDD) in Automation testing

  December 1, 2019
    •  Behavior-driven development (BDD) is an Agile software development methodology in which an application is documented and designed around the behavior a user expects to experience when interacting with it.
    •  BDD emerged from and extends TDD. Instead of writing unit tests from specification why not make the specification a test itself. The main idea is that business analysts, project managers, users or anyone without technical, but with sufficient business, knowledge can define tests.
    •  A typical project using behavior-driven development would begin with a conversation between the developers, managers, and clients to form an overall picture of how a product is intended to work. The expectations for the product's behavior are then set as goals for the developers, and once all of the behavior tests are passed the product has met its requirements and it ready for delivery to the customer.

  • Features of BDD

    •  Provides Collaboration between Business stakeholders, Business Analysts, QA Team, and developers
    •  Common language, it is easy to describe
    •  Driven by Business Value
    •  Extends Test-Driven Development (TDD) by utilizing natural language that non-technical stakeholders can understand
    •  BDD frameworks such as Cucumber or Specflow are an enabler, acting a “bridge” between Business & Technical Language
    •  Helps with implementing shift-left testing.

  • Gherkin

  • As described BDD follows a Common language, In order to make documentation sufficient for testing, it should follow some rules. This is where Gherkin comes into place. It is a Business Readable, Domain Specific Language created especially to describe behavior without defining how to implement it.

    Gherkin Keywords

    •  Example (or Scenario)
    •  Given, When, Then, And, But (steps)
    •  Background
    •  Scenario Outline (or Scenario Template)
    •  Examples

  • Feature

  • The purpose of the Feature keyword is to provide a high-level description of a software feature and to group related scenarios.

  • Scenario

  • The scenario describes the steps and expected outcomes for a particular test case.
    • BDD Tools

  • Cucumber (For java)


  • Cucumber is a testing framework which supports Behavior Driven Development (BDD). It lets us define application behavior in plain meaningful English text using a simple grammar defined by a language called Gherkin. Cucumber itself is written in Ruby, but it can be used to “test” code written in Ruby or other languages including but not limited to Java, C#, and Python.

  • Specflow (For C#)

  • SpecFlow is inspired by Cucumber framework in the Ruby on Rails world. Cucumber uses plain English in the Gherkin format to express user stories. Once the user stories and their expectations are written, the Cucumber gem is used to execute those stores. SpecFlow brings the same concept to the .NET world and allows the developer to express the feature in plain English language. It also allows to write specification in human readable Gherkin format.

  • Feature file

  • Parts of feature file

    •  Context
    •  Event
    •  Outcome

  • Multiline arguments

  • The regular expression matching in steps lets you capture small strings from your steps and receive them in your step definitions. However, there are times when you want to pass a richer data structure from a step to a step definition.
    This is what multiline step arguments are for. They are written on lines immediately following a step, and are passed to the step definition method as the last argument.

  • Backgrounds and Tags

  • Backgrounds allows you to add some context to all scenarios in a single feature. A Background is like an untitled scenario, containing a number of steps. The difference is when it is run: the background is run before each of your scenarios, but after your BeforeScenario hooks where as Tags are a great way to organize your features and scenarios. Eg: @SmokeTest ,@UITest etc

  • BDD in Azure

  • Many teams that are currently in a transformation process towards using agile and BDD have to face the problem that the new specification artifacts and reports have to be integrated into the existing toolchain.
    Since Azure is having an important role in manual test creation and automation execution, it is one of the major tools comes in the project chain

  • SpecSyc for specflow

 SpecSync for Azure DevOps is a synchronization tool that integrates SpecFlow to Azure DevOps. SpecSync can synchronize any scenarios that are written in Gherkin format.

The latest version of SpecSync all unit test providers (MsTest, xUnit, NUnit, SpecFlow+ Runner) are supported even for synchronizing automated test cases. The synchronized non-automated test cases can be managed, linked, and structured in Azure DevOps. You can also run them manually.

If we are using SpecSync to associate our test scenarios with the test cases in azure, it will be shown in the below format.







To conclude BDD mainly focus on the UAT part, and it came from an idea that what if most of the functional and non-functional test cases can be automated and what about UAT.
So here BDD helps even non-technical people to understand, execute and even minor modification can be done from their side. 
Hope the "Plain English" syntax, Not so easy way of writing test cases, etc now makes sense!

logoblog

Thanks for reading What is the use of Behavior Driven Development (BDD) in Automation testing

Previous
« Prev Post

No comments:

Post a Comment

Fixing javascript error: Cannot read properties of null (reading 'querySelector') issue when using CSS identifier in selenium

 JavaScript is another way to interact with web elements when normal selenium methods fail to act. But one issue with javascript is, it does...