Blog

Articles in category BDD

What is BDD?

2019-04-24 · BDD · Thomas Sundberg

Defining what Behaviour-Driven Development, BDD, is not easy. It is sometimes described as a bounded context of ideas.

What is rather clear to me is that there are a two properties everyone seems to be able to agree upon.

These are:

  • Conversations - talk to each other and get a better understanding
  • Concrete examples - share concrete usage examples for a better understanding

In order to get full benefit from these, I want to add

  • Automated acceptance tests - transform the concrete examples into executables examples
  • Code - write the production code that implement the rules checked by the concrete examples

to the list.

Read more →

I T.A.K.E. Unconference 2018

2018-05-20 · BDD Presentation Selenium · Thomas Sundberg

In june 2018 I will return to I T.A.K.E. Unconference in Bucharest, Romania. I run two sessions there:

These two sessions combine something I think is very important. They combine clean and understandable code with discovering what to implement. Understanding what to do is often more valuable than to know how to implement something. Implementing the wrong solution may even be harmful and is just as much waste as implementing something wrong.

Read more →

What does BDD really stand for?

2018-04-17 · BDD Cucumber Executable specification · Thomas Sundberg

BDD is the acronym for Behaviour-Driven Development. It is a way to describe the behaviour of a system and a way to make sure that it is developed to behave as it should.

BDD is used for understanding what to create and for verifying the result.

Business-Driven Development

But BDD could also be the acronym for Business-Driven Development. BDDers work really hard to bridge the communication gap between development and business. We really try to involve the business people in the development. We value their input and love discussing concrete examples describing what the system should do. How it is done is less important when understanding what really matters for the business. Focusing on the what and not the how is a differentiator between communicative developers and regular developers.

Read more →

Finding the Unknown Unknown

2017-12-20 · BDD · Thomas Sundberg

What is the unknown unknown?

The unknown unknown are the things, sometimes problems, of the task we are trying to achieve that no one has thought of. It is on the level that nobody is even aware about them, therefore the name unknown unknown. We don’t even know that we have a problem in this area. This is where the nasty bugs live and thrive in a software system.

Read more →

Gherkin scenarios - some good properties

2017-05-29 · BDD Cucumber Executable specification · Thomas Sundberg

Are there any global properties that a Gherkin scenario should fulfill? A short answer is, no.

A longer answer is that there are some properties that are good and probably useful in many different contexts.

Read more →

Organising scenarios and steps in Cucumber

2017-04-28 · BDD Cucumber · Thomas Sundberg

Writing a few scenarios in a feature file is easy. After while, when you have a lot of scenarios, you may want to divide them. How should you split them in such a way that finding a specific scenario is easy?

In the beginning it is easy to write the glue code needed to connect your scenarios with the system under test. But after a while it gets messy. You have a lot of methods and finding the one you need gets harder and harder. You need to start organising the steps in a good way to be able to find them without to much hassle.

These divisions can be done in a number of different ways. Some may support your development and maintenance. Other may hinder you. Is there an optimal division?

Read more →

How do you create a good specification?

2017-02-26 · BDD Cucumber Executable specification Requirements · Thomas Sundberg

A good specification is

  • Easy to understand
  • Executable
  • Acting as an acceptance criteria

An interesting question is "How do you create a good specification?" There are obviously a lot of different ways to end up with a good specification. You may be lucky and randomly end up with something good. There are, however, better ways than to rely on luck.

Read more →

What is the difference between a specification and a good specification?

2017-01-30 · BDD Cucumber Executable specification Requirements · Thomas Sundberg

What makes one specification a bad specification and another specification a good specification? What is the fundamental difference between two specifications?

Read more →

Cucumber and Gherkin are not about flexibility

2016-12-04 · BDD Cucumber Executable specification · Thomas Sundberg

Sometimes I see questions asking for flexibility in Gherkin, the language used by Cucumber. The purpose is often to remove duplication. An example may be this Stackoverflow question

Removing duplication is often a very a good thing. It is, however, sometimes better to keep duplication and gain clarity and readability.

Read more →

The Right Tool for the Job

2016-07-25 · BDD Cucumber Test automation · Thomas Sundberg

No tool is perfect for all jobs. When you start out automating Behvaiour-Driven Development, BDD, using Cucumber you tend to use it for much more than you need. This will work, but it is not a good idea for a few reasons:

  • Cucumber is not a testing tool, it is a collaboration tool
  • Unnecessarily complicated, testing tools like JUnit are easier to use

Read more →

Cucumber Anti-Patterns

2016-06-22 · BDD Cucumber · Thomas Sundberg

This a transcript and interpretation of a podcast where Aslak Hellesøy, Matt Wynne, and Steve Tooke from Cucumber Ltd have a chat about the BDD tool Cucumber and anti-patterns they have come across.

I have changed the order of the patterns described, rephrased some parts, and added a few of my own thoughts. The original podcast is available at https://cucumber.io/blog/2016/05/09/cucumber-antipatterns.
It is worth your time to listen to it.

Read more →

Where should you use Behaviour Driven Development, BDD?

2016-03-26 · BDD Cucumber · Thomas Sundberg

When I was at the European Testing Conference 2016 in Bucharest, a colleague asked me about my thoughts on how they should use Behaviour Driven Development, BDD. I didn't get a good chance to elaborate on my view so I decided that I should write this instead.

Read more →

BDD with Cucumber-JVM at GeeCON TDD 2015

2015-01-30 · BDD Cucumber Java · Thomas Sundberg

This blog post is the same as the example I presented at GeeCON TDD in Poznan, Poland, January 2015. It is a step-by-step example that I hope you will be able to follow and implement yourself.

But before I begin with the implementation, let me reason about why you should care about BDD.

Behaviour Driven Development, BDD, is a way to try to bridge the gap between developers, who can read code, and people who are less fluent in reading code. Cucumber is not a tool only for acceptance testing. It is a communication tool where you can express examples in plain text that anyone can read. These examples can also be executed. They are the outcome from discussions between stakeholders, developers and testers.

Given this, the technical part of BDD that I will show you is the less important part. The most important part is the conversations that occurs and defines the application that should be implemented.

Read more →

System Under Specification, SUS

2013-10-15 · BDD · Thomas Sundberg

Ian Kelly called the System Under Test, SUT, the System Under Specification, SUS, at his session “Testing++ – Working with Spock and Geb” on Java Developer Day in Krakow.

Read more →

Cucumber-JVM - not just for testing GUIs

2012-11-01 · BDD Cucumber Test automation · Thomas Sundberg

Cucumber is a tool that supports Behaviour Driven Development, BDD. A lot of people think that the only place where a system has behaviour is in the user interface and especially in the graphical user interface. As a developer I know that this is not the case. All systems have behaviour at different places and different levels.

I will show an example of how a system can be developed using its desired behaviour and start from a non graphical point. I will work from the model down to the database and when I'm happy with the logical behaviour I will add a graphical user interface on top of it. I will actually add a few different interfaces; two web-based, one swing and two different types of web services. The result will be an example of Model View Controller, MVC, developed using BDD.

An important point when I add the GUIs or web services is that I will not change the desired behaviour. I will only change how the behaviour is verified. This is one way of showing you that Cucumber and BDD is not about testing GUIs. It is about systems behaviour.

Read more →

Building the model

2012-11-01 · BDD Cucumber Test automation · Thomas Sundberg

Previous - Introduction

The feature I will start with looks like this:

src/test/resources/se/waymark/rentit/Rent.feature

Feature: Rental cars should be possible to rent to gain revenue to the rental company.

  As an owner of a car rental company
  I want to make cars available for renting
  So I can make money

  Scenario: Find and rent a car
    Given there are 18 cars available for rental
    When I rent one
    Then there will only be 17 cars available for rental

It consists of three parts:

  • Given - the preconditions of the system under test. The setup of the systems state if you want. In this case make 18 compact cars available for rental in the system.
  • When - the actual change of the system. Transforming it from the initial state to the final state. Rent one car.
  • Then - the expected final state of the system. The verification that the state change was the desired change. After one car is rented, there should only be 17 left to rent.

Read more →

A JSF web application

2012-11-01 · BDD Cucumber Test automation · Thomas Sundberg

Previous - Building the model

Many modern applications are built as web applications. The benefits are obvious, you don't need to package your software in shrink-wrap and send it to your customers. Upgrading is easy, you have to upgrade the server you host the system on and that's it.

The first user interface I will add to the rental system will therefore be a web GUI. It will be the simplest possible solution and the goal is not to build a fancy web app. The goal is to show how Cucumber can control a tool like Selenium WebDriver to assert the behaviour of the web application.

Read more →

A Wicket web application

2012-11-01 · BDD Cucumber Test automation · Thomas Sundberg

Previous - A JSF web application

A wicket application is yet another web application. I divide the project in two parts as earlier. The only large difference is the support class that will connect to the system under test. It has been adapted for another web application.

Read more →

Building a Swing GUI

2012-11-01 · BDD Cucumber Test automation · Thomas Sundberg

Previous - A Wicket web application

A Java Swing application is yet another graphical user interface that can be attached on top of the model developed earlier. The project is divided in the same way as earlier, in two parts. The only large difference here is the support class. It need to be adapted for a Swing user interface. Another difference is of obviously that the GUI is developed using Swing. But that has actually a rather small impact on the verification.

Read more →

A RESTFul Web Service

2012-11-01 · BDD Cucumber Test automation · Thomas Sundberg

Previous - A Swing application

A RESTFul web service is yet another way to use the model. It doesn't have any user interface and it is expected to be used by third party suppliers. I divide the project using two Maven modules as earlier. One for the production code and one for the verification. The only large difference here is the support class that will connect to the system under test but now has to be adapted for a RESTFul web service instead of any graphical interface. Another difference is of course that there is no GUI and that it is developed using a Jersey servlet instead, but that has little impact on the verification.

Read more →

A SOAP Web Service

2012-11-01 · BDD Cucumber Test automation · Thomas Sundberg

Previous - A RESTFul web service

A SOAP Web Service is yet another way to use the model. It doesn't have any user interface and is expected to be used by third party suppliers. I divide the project using two Maven modules as earlier. One for the production code and one for the verification. The only large difference here is the support class that will connect to the system under test but now has to be adapted for a SOAP web service instead of any graphical interface or RESTFul web service. Another difference is of course that there is no GUI and that it is developed using a CXF instead, but that has little impact on the verification.

Read more →

Conclusion

2012-11-01 · BDD Cucumber Test automation · Thomas Sundberg

Previous - A SOAP web service

I have shown you five different ways to implement something on top of a common model using the same behaviour. I hope you can agree that it is obvious that BDD and Cucumber-JVM is not just meant for testing GUIs. It can be used to assert any behaviour.

Read more →