Behavioral Driven Development for our Web Application
What is Behavioral Driven Development [ref: Behavior-driven development – Wikipedia, the free encyclopedia]
- Software process similar to Test Driven Development.
- Manages both business interests and technical insight.
- Process to convert User stories, Backlog Item’s Acceptance test into Automated test-cases for continuous integration.
Is it something really new?
In short: Not really, but it has value.
When explaining a complete stranger about BDD, the feedback was it looks like Acceptance test. While BDD is a process, Acceptance test is result of this process. The process has over period of time matured that we have tools to automate the Acceptance test and run it to identify:
- Is there any regression in my functionality?
- If some code isn’t working as expected which ‘User story’ or ‘Backlog Item’ or to be specific which scenario isn’t working.
How are we doing it?
[CAUTION]: Things I am about to explain is not for the faint heart. There are terminologies thrown left-right-&-center.
- List of technologies used currently: ‘Cucumber’, ‘Gherkin’, ‘Ruby’, ‘Capybara’ (wrapper over selenium driver) to write Q2 Automated Functional Test for our Web based tool (SAPUI5)
- The four quadrants: Very popular diagram part of Agile Testing methodologies (Source: SAP Public). We are talking about Q2 here (automated & functional)
- Flow diagram representing the complete steps we follow in our team to write Q2 test (Functional Tests) for our Browser based application (SAPUI5)
- Install Ruby (http://rubyinstaller.org/downloads/ — Installer name: Ruby 1.9.3-p125). Note: Read the options during installations, one of them should allow to add Ruby in PATH, make sure it is checked.
- Install DevKit (http://rubyinstaller.org/downloads/ — Installer name: DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe). Note: DevKit is self extractable, thus specify folder inside the installed ruby directory (Eg: Ruby is installed in C:\Ruby193, then Dev Kit should be installed in C:\Ruby193\devkit)
- Go to command prompt (inside DevKit folder) and run few commands to install ruby gems.
- ruby dk.rb init
- ruby dk.rb install –force
- gem install rdiscount –platform=ruby [Note: rdiscount gem should be installed successfully]
- gem install cucumber
- gem install capybara
- gem install rspec
- gem install rubygems-update
- Install chrome driver from location: http://chromedriver.storage.googleapis.com/index.html
- Download the attachment (it is a zip), which is sample cucumber file. Run the command ‘cucumber firstfeature.feature’ to see how ‘scenarios’ are defined and ‘step definitions’ are created.
What are the benefits?
- The feature file which is written is in ‘Plain English’ and hence involves “ALL” (Product Owner, Quality colleagues, Testers and Developers)
- Gives feature level clarity in case of failures or regression
What are the drawbacks?
- It is a change which at times is difficult to adapt. Like Quality is habit, BDD can also become habit
- It has a steep learning curve and require ‘utmost’ attention.
My own verdict?
Even though there are school of thoughts ‘for’ and ‘against’ the process, it is another form of Safety Net which assists every sprint how are the software increments building without affecting existing functionality.
- For Web based application it is robust and can be used with lot of Open-source technologies available.
- For Eclipse based development BDD can be triggered using JBehave or Cucumber-JVM. If anyone has experience with this – do share!!!