• 1. Sogeti
  • 2. JBoss
  • 3. IBM
  • 4. Oracle
  • 5. SpringSource
  • 6. NL-JUG
  • 7. Java


Syndication  RSS 2.0

RSS 1.0
RSS 2.0

Bookmark this site

Add 'JCN Blog' site to delicious  Add 'JCN Blog' site to technorati  Add 'JCN Blog' site to digg  Add 'JCN Blog' site to dzone

Posted by Jan-Hendrik Kuperus at 23:55 on Monday 15 March    Add '/dev/brainst||m – Behavior Driven Development' site to delicious  Add '/dev/brainst||m – Behavior Driven Development' site to technorati  Add '/dev/brainst||m – Behavior Driven Development' site to digg  Add '/dev/brainst||m – Behavior Driven Development' site to dzone

On our most recent installment of a /dev/brainst||m meeting, we took a dive into Behavior Driven Development. Our colleague Maarten van Berkel uses BDD at his client’s project to facilitate better development and better testing of their Ruby software.

Behavior Driven Development (BDD) is a method for developing software much like Test Driven Development (TDD). Both methods start development with specifying test cases for a feature. The big difference lies in the way these tests are defined. TDD generally defines its scenarios in unit tests expressed in some programming language. BDD lets you specify your test scenario’s in plain English (or Dutch, or whatever). This forces you to think in working features over working units of code.

For example, a test scenario for a web application in BDD would look like this:

 1  2  3 Given I am on the homepage When I click 'Login' Then I get to view the Login page

This little script describes a test scenario and can actually be executed. The trick is that the test scenario is broken down into preconditions (Given keyword), actions (When keyword) and postconditions (Then keyword). This actually describes the behavior that is expected of the application, in plain English.

A BDD test framework, like JBehave, interprets these scripts and maps the statements to function calls in your test. It allows you to create reusable statements like I click $pagename, which the test translates into some action within the application. For more information, you are encouraged to try out JBehave (see link below).

In order to automatically test a web application in an actual browser, we used Selenium to perform these tasks. Selenium is a browser automation tool that allows for real testing of web applications. The code of the test uses Selenium to interact with the browser and perform actions that a real user would also perform.

Tonight’s workshop gave us a good feeling in JBehave/Selenium testing based on some BDD principles. Most of us however concluded it would be difficult to integrate such testing in existing projects.

Have you used BDD and/or JBehave testing in a project recently? We’d like to hear your experiences! Mail me at jan-hendrik [dot] kuperus [at] sogeti [dot] nl.

Further reading:

A little impression of tonight’s /dev/brainst||m:

Impression of tonight's /dev/brainst||m Maarten showing us the ropes


© 2020 Java Competence Network. All Rights Reserved.